Class: Astroapi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/astroapi/client.rb

Overview

Main client for the Astrology API

Examples:

Initialize with API key

client = Astroapi::Client.new(api_key: 'your-api-key')

Initialize with configuration block

client = Astroapi::Client.new do |config|
  config.api_key = 'your-api-key'
  config.timeout = 15
  config.debug = true
end

Use environment variables

ENV['ASTROLOGY_API_KEY'] = 'your-api-key'
client = Astroapi::Client.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|config| ... } ⇒ Client

Initialize a new client

Parameters:

  • options (Hash) (defaults to: {})

    Configuration options

Options Hash (options):

  • :api_key (String)

    API key for authentication

  • :base_url (String)

    Base URL for the API

  • :timeout (Integer)

    Request timeout in seconds

  • :debug (Boolean)

    Enable debug logging

Yields:

  • (config)

    Configuration block

Yield Parameters:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/astroapi/client.rb', line 63

def initialize(options = {})
  @config = Configuration.new

  if block_given?
    yield @config
  else
    options.each do |key, value|
      @config.public_send(:"#{key}=", value) if @config.respond_to?(:"#{key}=")
    end
  end

  @http_client = HTTP::Client.new(@config)

  @data = Categories::Data.new(@http_client)
  @charts = Categories::Charts.new(@http_client)
  @horoscope = Categories::Horoscope.new(@http_client)
  @analysis = Categories::Analysis.new(@http_client)
  @glossary = Categories::Glossary.new(@http_client)
  @astrocartography = Categories::Astrocartography.new(@http_client)
  @chinese = Categories::Chinese.new(@http_client)
  @eclipses = Categories::Eclipses.new(@http_client)
  @lunar = Categories::Lunar.new(@http_client)
  @numerology = Categories::Numerology.new(@http_client)
  @tarot = Categories::Tarot.new(@http_client)
  @traditional = Categories::Traditional.new(@http_client)
  @fixed_stars = Categories::FixedStars.new(@http_client)
  @insights = Categories::InsightsCategory.new(@http_client)
  @svg = Categories::Svg.new(@http_client)
  @enhanced = Categories::Enhanced.new(@http_client)
  @vedic = Categories::Vedic.new(@http_client)
  @human_design = Categories::HumanDesign.new(@http_client)
  @kabbalah = Categories::Kabbalah.new(@http_client)
  @horary = Categories::Horary.new(@http_client)
  @fengshui = Categories::Fengshui.new(@http_client)
  @palmistry = Categories::Palmistry.new(@http_client)
  @pdf = Categories::Pdf.new(@http_client)
  @render = Categories::Render.new(@http_client)
  @ziwei = Categories::Ziwei.new(@http_client)
end

Instance Attribute Details

#analysisObject (readonly)

Returns the value of attribute analysis.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def analysis
  @analysis
end

#astrocartographyObject (readonly)

Returns the value of attribute astrocartography.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def astrocartography
  @astrocartography
end

#chartsObject (readonly)

Returns the value of attribute charts.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def charts
  @charts
end

#chineseObject (readonly)

Returns the value of attribute chinese.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def chinese
  @chinese
end

#configObject (readonly)

Returns the value of attribute config.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def config
  @config
end

#dataObject (readonly)

Returns the value of attribute data.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def data
  @data
end

#eclipsesObject (readonly)

Returns the value of attribute eclipses.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def eclipses
  @eclipses
end

#enhancedObject (readonly)

Returns the value of attribute enhanced.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def enhanced
  @enhanced
end

#fengshuiObject (readonly)

Returns the value of attribute fengshui.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def fengshui
  @fengshui
end

#fixed_starsObject (readonly)

Returns the value of attribute fixed_stars.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def fixed_stars
  @fixed_stars
end

#glossaryObject (readonly)

Returns the value of attribute glossary.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def glossary
  @glossary
end

#horaryObject (readonly)

Returns the value of attribute horary.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def horary
  @horary
end

#horoscopeObject (readonly)

Returns the value of attribute horoscope.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def horoscope
  @horoscope
end

#human_designObject (readonly)

Returns the value of attribute human_design.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def human_design
  @human_design
end

#insightsObject (readonly)

Returns the value of attribute insights.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def insights
  @insights
end

#kabbalahObject (readonly)

Returns the value of attribute kabbalah.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def kabbalah
  @kabbalah
end

#lunarObject (readonly)

Returns the value of attribute lunar.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def lunar
  @lunar
end

#numerologyObject (readonly)

Returns the value of attribute numerology.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def numerology
  @numerology
end

#palmistryObject (readonly)

Returns the value of attribute palmistry.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def palmistry
  @palmistry
end

#pdfObject (readonly)

Returns the value of attribute pdf.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def pdf
  @pdf
end

#renderObject (readonly)

Returns the value of attribute render.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def render
  @render
end

#svgObject (readonly)

Returns the value of attribute svg.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def svg
  @svg
end

#tarotObject (readonly)

Returns the value of attribute tarot.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def tarot
  @tarot
end

#traditionalObject (readonly)

Returns the value of attribute traditional.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def traditional
  @traditional
end

#vedicObject (readonly)

Returns the value of attribute vedic.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def vedic
  @vedic
end

#ziweiObject (readonly)

Returns the value of attribute ziwei.



48
49
50
# File 'lib/astroapi/client.rb', line 48

def ziwei
  @ziwei
end