astroinsightapi-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +153 -0
- data/lib/astroinsight/client.rb +46 -0
- data/lib/astroinsight/configuration.rb +28 -0
- data/lib/astroinsight/error.rb +28 -0
- data/lib/astroinsight/http_client.rb +82 -0
- data/lib/astroinsight/models/birth_details.rb +39 -0
- data/lib/astroinsight/models/geo_location.rb +27 -0
- data/lib/astroinsight/models/match_input.rb +46 -0
- data/lib/astroinsight/services/chinese_astrology.rb +35 -0
- data/lib/astroinsight/services/geo.rb +23 -0
- data/lib/astroinsight/services/horoscope.rb +37 -0
- data/lib/astroinsight/services/tarot.rb +51 -0
- data/lib/astroinsight/services/vedic/ashtakvarga.rb +25 -0
- data/lib/astroinsight/services/vedic/astro_details.rb +48 -0
- data/lib/astroinsight/services/vedic/biorhythm.rb +18 -0
- data/lib/astroinsight/services/vedic/char_dasha.rb +30 -0
- data/lib/astroinsight/services/vedic/horoscope_chart.rb +25 -0
- data/lib/astroinsight/services/vedic/horoscope_dosha.rb +33 -0
- data/lib/astroinsight/services/vedic/jaimini.rb +23 -0
- data/lib/astroinsight/services/vedic/kp.rb +28 -0
- data/lib/astroinsight/services/vedic/lal_kitab.rb +35 -0
- data/lib/astroinsight/services/vedic/life_report.rb +18 -0
- data/lib/astroinsight/services/vedic/match_making.rb +28 -0
- data/lib/astroinsight/services/vedic/muhurta.rb +35 -0
- data/lib/astroinsight/services/vedic/numerology.rb +18 -0
- data/lib/astroinsight/services/vedic/panchang.rb +28 -0
- data/lib/astroinsight/services/vedic/suggestions.rb +28 -0
- data/lib/astroinsight/services/vedic/varshaphal.rb +38 -0
- data/lib/astroinsight/services/vedic/vimshottari_dasha.rb +40 -0
- data/lib/astroinsight/services/vedic/yogini_dasha.rb +28 -0
- data/lib/astroinsight/services/vedic_container.rb +52 -0
- data/lib/astroinsight/services/western/natal_astrology.rb +33 -0
- data/lib/astroinsight/services/western/solar_return.rb +33 -0
- data/lib/astroinsight/services/western/transit.rb +43 -0
- data/lib/astroinsight/services/western/transit_chart.rb +23 -0
- data/lib/astroinsight/services/western/western_numerology.rb +38 -0
- data/lib/astroinsight/services/western/zodiac.rb +23 -0
- data/lib/astroinsight/services/western_container.rb +25 -0
- data/lib/astroinsight/version.rb +5 -0
- data/lib/astroinsight.rb +18 -0
- data/lib/astroinsightapi-sdk.rb +3 -0
- metadata +89 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: be7de757a8f0f76a1be44455df4f1ec3ec9ec00a8d734c2dde38d9e795ed3d76
|
|
4
|
+
data.tar.gz: a1557523f2eeeeb51820af64ea67cb75b576484133795b30a3925b4e01a0d69e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 68cab9919e0a29b4c1ae09384071fa4cc3849d044552fd2194fd573aff6cfc171c7e5e2f0bbb8b49ad867ddb7fadf21eba5a63eff9faf7fdef2eb7bb875215bf
|
|
7
|
+
data.tar.gz: bb15541f85527eee6e722fcc56aa6fac065846b9fad1ee6ecf528b2db73524b02e61be8426d5bdf169ab7b64d090a313049ad7fae774d77511d3f6e0b2473a81
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Astro Insight
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# astroinsightapi-sdk (Ruby Gem)
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/astroinsightapi-sdk)
|
|
4
|
+
[](https://www.ruby-lang.org/)
|
|
5
|
+
[](LICENSE.txt)
|
|
6
|
+
|
|
7
|
+
Official, idiomatic **Ruby Gem** for the **Astro Insight API**. Provides zero-dependency, pure Ruby access to Vedic Astrology, Western Astrology, Matchmaking, Panchang, Muhurta, Tarot, Numerology, Chinese Astrology, and Geolocation services.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 🪐 **Vedic Astrology**: Ashtakvarga, Vimshottari / Char / Yogini Dashas, KP System, Jaimini, Lal Kitab, Varshaphal, Ghat Chakra, Horoscope Charts & Doshas.
|
|
14
|
+
- 💍 **Matchmaking**: Guna Milan, Kundali Compatibility, Manglik Matching.
|
|
15
|
+
- 🗓️ **Panchang & Muhurta**: Daily Panchang, Choghadiya, Hora, Shubh Muhurta timing.
|
|
16
|
+
- 🔮 **Western Astrology & Tarot**: Natal Charts, Solar Return, Transits, Synastry, Tarot spreads (One-card, Three-card, Celtic Cross, Love, Career).
|
|
17
|
+
- 🔢 **Numerology**: Vedic & Western Numerology (Life Path, Destiny, Soul Urge).
|
|
18
|
+
- ☯️ **Chinese Astrology & Biorhythm**: Zodiac sign compatibility & biorhythm calculations.
|
|
19
|
+
- 🌍 **Geo Utilities**: Place search, timezone lookup by coordinates or ID.
|
|
20
|
+
- ⚡ **Zero External Dependencies**: Pure Ruby `Net::HTTP` transport.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Add this line to your application's `Gemfile`:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
gem 'astroinsightapi-sdk'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
And then execute:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bundle install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or install it directly via `gem`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
gem install astroinsightapi-sdk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
require 'astroinsightapi-sdk'
|
|
50
|
+
|
|
51
|
+
client = AstroInsight::Client.new(
|
|
52
|
+
client_id: 'YOUR_CLIENT_ID',
|
|
53
|
+
client_secret: 'YOUR_CLIENT_SECRET'
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
birth = AstroInsight::Models::BirthDetails.new(
|
|
57
|
+
day: 15, month: 8, year: 1995,
|
|
58
|
+
hour: 10, min: 30, sec: 0,
|
|
59
|
+
tzone: 5.5, lat: 28.6139, lon: 77.2090
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Fetch Birth Details
|
|
63
|
+
details = client.vedic.astro_details.get_birth_details(birth)
|
|
64
|
+
puts details['data']['birth_details']['day'] # Tuesday
|
|
65
|
+
|
|
66
|
+
# Fetch Sun Bhinnashtakavarga
|
|
67
|
+
ashtak = client.vedic.ashtakvarga.get_planet_ashtak('sun', birth)
|
|
68
|
+
|
|
69
|
+
# One Card Tarot Reading
|
|
70
|
+
tarot = client.tarot.get_one_card_reading
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Code Examples
|
|
76
|
+
|
|
77
|
+
### 🪐 Vedic Astrology & Dashas
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
# Major Vimshottari Dasha
|
|
81
|
+
dasha = client.vedic.vimshottari_dasha.get_major_dasha(birth)
|
|
82
|
+
|
|
83
|
+
# Gemstone Suggestions
|
|
84
|
+
remedies = client.vedic.suggestions.get_gemstone_suggestions(birth)
|
|
85
|
+
|
|
86
|
+
# Manglik Dosha Check
|
|
87
|
+
manglik = client.vedic.horoscope_dosha.get_manglik_dosha(birth)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 💍 Matchmaking (Guna Milan)
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
male = AstroInsight::Models::BirthDetails.new(day: 15, month: 8, year: 1995, hour: 10, min: 30)
|
|
94
|
+
female = AstroInsight::Models::BirthDetails.new(day: 20, month: 11, year: 1997, hour: 14, min: 15)
|
|
95
|
+
|
|
96
|
+
match_input = AstroInsight::Models::MatchInput.new(male: male, female: female)
|
|
97
|
+
|
|
98
|
+
# Calculate Guna Milan
|
|
99
|
+
score = client.vedic.match_making.get_guna_milan(match_input)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 🗓️ Daily Panchang & Muhurta
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
panchang = client.vedic.panchang.get_daily_panchang(birth)
|
|
106
|
+
choghadiya = client.vedic.muhurta.get_choghadiya(birth)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 🔮 Horoscope & Geo Services
|
|
110
|
+
|
|
111
|
+
```ruby
|
|
112
|
+
# Daily Horoscope for Leo
|
|
113
|
+
leo_daily = client.horoscope.get_daily_horoscope('leo')
|
|
114
|
+
|
|
115
|
+
# Search Place Coordinates
|
|
116
|
+
place_info = client.geo.search_place('Delhi')
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Dynamic Configuration & Headers
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
# Switch language dynamically
|
|
125
|
+
client.set_language('hi')
|
|
126
|
+
|
|
127
|
+
# Switch Ayanamsha system
|
|
128
|
+
client.set_ayanamsha('raman')
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Error Handling
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
begin
|
|
137
|
+
response = client.vedic.astro_details.get_birth_details(birth)
|
|
138
|
+
rescue AstroInsight::AuthenticationError => e
|
|
139
|
+
puts "Auth failed: #{e.message}"
|
|
140
|
+
rescue AstroInsight::ValidationError => e
|
|
141
|
+
puts "Validation failed: #{e.message}, Errors: #{e.errors}"
|
|
142
|
+
rescue AstroInsight::RateLimitError => e
|
|
143
|
+
puts "Rate limit exceeded. Retry later."
|
|
144
|
+
rescue AstroInsight::Error => e
|
|
145
|
+
puts "API Error [#{e.status_code}]: #{e.message}"
|
|
146
|
+
end
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
This Gem is open-sourced software licensed under the [MIT License](LICENSE.txt).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "configuration"
|
|
4
|
+
require_relative "http_client"
|
|
5
|
+
require_relative "services/vedic_container"
|
|
6
|
+
require_relative "services/western_container"
|
|
7
|
+
require_relative "services/horoscope"
|
|
8
|
+
require_relative "services/tarot"
|
|
9
|
+
require_relative "services/chinese_astrology"
|
|
10
|
+
require_relative "services/geo"
|
|
11
|
+
|
|
12
|
+
module AstroInsight
|
|
13
|
+
class Client
|
|
14
|
+
attr_reader :config, :http_client, :vedic, :western, :horoscope, :tarot, :chinese, :geo
|
|
15
|
+
|
|
16
|
+
def initialize(client_id: nil, client_secret: nil, base_url: nil, language: "en", ayanamsha: "lahiri", timeout: 30)
|
|
17
|
+
@config = Configuration.new(
|
|
18
|
+
client_id: client_id,
|
|
19
|
+
client_secret: client_secret,
|
|
20
|
+
base_url: base_url,
|
|
21
|
+
language: language,
|
|
22
|
+
ayanamsha: ayanamsha,
|
|
23
|
+
timeout: timeout
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
@http_client = HttpClient.new(@config)
|
|
27
|
+
|
|
28
|
+
@vedic = Services::VedicContainer.new(@http_client)
|
|
29
|
+
@western = Services::WesternContainer.new(@http_client)
|
|
30
|
+
@horoscope = Services::HoroscopeService.new(@http_client)
|
|
31
|
+
@tarot = Services::TarotService.new(@http_client)
|
|
32
|
+
@chinese = Services::ChineseAstrologyService.new(@http_client)
|
|
33
|
+
@geo = Services::GeoService.new(@http_client)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def set_language(language)
|
|
37
|
+
@config.language = language
|
|
38
|
+
self
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def set_ayanamsha(ayanamsha)
|
|
42
|
+
@config.ayanamsha = ayanamsha
|
|
43
|
+
self
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AstroInsight
|
|
4
|
+
class Configuration
|
|
5
|
+
attr_accessor :client_id, :client_secret, :base_url, :language, :ayanamsha, :timeout
|
|
6
|
+
|
|
7
|
+
DEFAULT_BASE_URL = "https://json.astroinsightapi.com/api/v1/"
|
|
8
|
+
|
|
9
|
+
def initialize(client_id: nil, client_secret: nil, base_url: nil, language: "en", ayanamsha: "lahiri", timeout: 30)
|
|
10
|
+
@client_id = client_id
|
|
11
|
+
@client_secret = client_secret
|
|
12
|
+
url = base_url || DEFAULT_BASE_URL
|
|
13
|
+
@base_url = url.end_with?("/") ? url : "#{url}/"
|
|
14
|
+
@language = language
|
|
15
|
+
@ayanamsha = ayanamsha
|
|
16
|
+
@timeout = timeout
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def headers
|
|
20
|
+
{
|
|
21
|
+
"Accept" => "application/json",
|
|
22
|
+
"Content-Type" => "application/json",
|
|
23
|
+
"Accept-Language" => @language,
|
|
24
|
+
"X-Ayanamsha" => @ayanamsha
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AstroInsight
|
|
4
|
+
class Error < StandardError
|
|
5
|
+
attr_reader :status_code, :response_body
|
|
6
|
+
|
|
7
|
+
def initialize(message, status_code = nil, response_body = nil)
|
|
8
|
+
@status_code = status_code
|
|
9
|
+
@response_body = response_body
|
|
10
|
+
super(message)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class AuthenticationError < Error; end
|
|
15
|
+
|
|
16
|
+
class ValidationError < Error
|
|
17
|
+
attr_reader :errors
|
|
18
|
+
|
|
19
|
+
def initialize(message, status_code = 422, response_body = nil, errors = {})
|
|
20
|
+
@errors = errors
|
|
21
|
+
super(message, status_code, response_body)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class RateLimitError < Error; end
|
|
26
|
+
|
|
27
|
+
class ServerError < Error; end
|
|
28
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "uri"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module AstroInsight
|
|
8
|
+
class HttpClient
|
|
9
|
+
def initialize(config)
|
|
10
|
+
@config = config
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def post(endpoint, payload = {})
|
|
14
|
+
url = build_url(endpoint)
|
|
15
|
+
request = Net::HTTP::Post.new(url.path, @config.headers)
|
|
16
|
+
request.basic_auth(@config.client_id, @config.client_secret)
|
|
17
|
+
request.body = payload.respond_to?(:to_h) ? payload.to_h.to_json : payload.to_json
|
|
18
|
+
|
|
19
|
+
execute(url, request)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get(endpoint, params = {})
|
|
23
|
+
url = build_url(endpoint)
|
|
24
|
+
url.query = URI.encode_www_form(params) unless params.empty?
|
|
25
|
+
|
|
26
|
+
request = Net::HTTP::Get.new(url.request_uri, @config.headers)
|
|
27
|
+
request.basic_auth(@config.client_id, @config.client_secret)
|
|
28
|
+
|
|
29
|
+
execute(url, request)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def build_url(endpoint)
|
|
35
|
+
clean_endpoint = endpoint.to_s.sub(%r{^/}, "")
|
|
36
|
+
URI.join(@config.base_url, clean_endpoint)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def execute(url, request)
|
|
40
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
41
|
+
http.use_ssl = (url.scheme == "https")
|
|
42
|
+
http.open_timeout = @config.timeout
|
|
43
|
+
http.read_timeout = @config.timeout
|
|
44
|
+
|
|
45
|
+
response = http.request(request)
|
|
46
|
+
data = parse_response(response.body)
|
|
47
|
+
|
|
48
|
+
unless response.is_a?(Net::HTTPSuccess)
|
|
49
|
+
handle_error(response.code.to_i, data, response.message)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
data
|
|
53
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
|
54
|
+
raise AstroInsight::Error.new("Network request failed: #{e.message}")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def parse_response(body)
|
|
58
|
+
return {} if body.nil? || body.strip.empty?
|
|
59
|
+
JSON.parse(body)
|
|
60
|
+
rescue JSON::ParserError
|
|
61
|
+
{}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def handle_error(status_code, data, message)
|
|
65
|
+
msg = data.is_a?(Hash) && data["message"] ? data["message"] : message
|
|
66
|
+
|
|
67
|
+
case status_code
|
|
68
|
+
when 401, 403
|
|
69
|
+
raise AstroInsight::AuthenticationError.new(msg, status_code, data)
|
|
70
|
+
when 422
|
|
71
|
+
errors = data.is_a?(Hash) && data["errors"] ? data["errors"] : {}
|
|
72
|
+
raise AstroInsight::ValidationError.new(msg, status_code, data, errors)
|
|
73
|
+
when 429
|
|
74
|
+
raise AstroInsight::RateLimitError.new(msg, status_code, data)
|
|
75
|
+
when 500..599
|
|
76
|
+
raise AstroInsight::ServerError.new(msg, status_code, data)
|
|
77
|
+
else
|
|
78
|
+
raise AstroInsight::Error.new(msg, status_code, data)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AstroInsight
|
|
4
|
+
module Models
|
|
5
|
+
class BirthDetails
|
|
6
|
+
attr_accessor :day, :month, :year, :hour, :min, :sec, :tzone, :lat, :lon
|
|
7
|
+
|
|
8
|
+
def initialize(day:, month:, year:, hour:, min:, sec: 0, tzone: 5.5, lat: 28.6139, lon: 77.2090)
|
|
9
|
+
@day = day.to_i
|
|
10
|
+
@month = month.to_i
|
|
11
|
+
@year = year.to_i
|
|
12
|
+
@hour = hour.to_i
|
|
13
|
+
@min = min.to_i
|
|
14
|
+
@sec = sec.to_i
|
|
15
|
+
@tzone = tzone.to_f
|
|
16
|
+
@lat = lat.to_f
|
|
17
|
+
@lon = lon.to_f
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_h
|
|
21
|
+
{
|
|
22
|
+
day: @day,
|
|
23
|
+
month: @month,
|
|
24
|
+
year: @year,
|
|
25
|
+
hour: @hour,
|
|
26
|
+
min: @min,
|
|
27
|
+
sec: @sec,
|
|
28
|
+
tzone: @tzone,
|
|
29
|
+
lat: @lat,
|
|
30
|
+
lon: @lon
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_json(*_args)
|
|
35
|
+
to_h.to_json
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AstroInsight
|
|
4
|
+
module Models
|
|
5
|
+
class GeoLocation
|
|
6
|
+
attr_accessor :lat, :lon, :tzone
|
|
7
|
+
|
|
8
|
+
def initialize(lat:, lon:, tzone: 5.5)
|
|
9
|
+
@lat = lat.to_f
|
|
10
|
+
@lon = lon.to_f
|
|
11
|
+
@tzone = tzone.to_f
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_h
|
|
15
|
+
{
|
|
16
|
+
lat: @lat,
|
|
17
|
+
lon: @lon,
|
|
18
|
+
tzone: @tzone
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def to_json(*_args)
|
|
23
|
+
to_h.to_json
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "birth_details"
|
|
4
|
+
|
|
5
|
+
module AstroInsight
|
|
6
|
+
module Models
|
|
7
|
+
class MatchInput
|
|
8
|
+
attr_accessor :male, :female
|
|
9
|
+
|
|
10
|
+
def initialize(male:, female:)
|
|
11
|
+
@male = male.is_a?(BirthDetails) ? male : BirthDetails.new(**male.transform_keys(&:to_sym))
|
|
12
|
+
@female = female.is_a?(BirthDetails) ? female : BirthDetails.new(**female.transform_keys(&:to_sym))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_h
|
|
16
|
+
m = @male.to_h
|
|
17
|
+
f = @female.to_h
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
m_day: m[:day],
|
|
21
|
+
m_month: m[:month],
|
|
22
|
+
m_year: m[:year],
|
|
23
|
+
m_hour: m[:hour],
|
|
24
|
+
m_min: m[:min],
|
|
25
|
+
m_sec: m[:sec],
|
|
26
|
+
m_tzone: m[:tzone],
|
|
27
|
+
m_lat: m[:lat],
|
|
28
|
+
m_lon: m[:lon],
|
|
29
|
+
f_day: f[:day],
|
|
30
|
+
f_month: f[:month],
|
|
31
|
+
f_year: f[:year],
|
|
32
|
+
f_hour: f[:hour],
|
|
33
|
+
f_min: f[:min],
|
|
34
|
+
f_sec: f[:sec],
|
|
35
|
+
f_tzone: f[:tzone],
|
|
36
|
+
f_lat: f[:lat],
|
|
37
|
+
f_lon: f[:lon]
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_json(*_args)
|
|
42
|
+
to_h.to_json
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
module AstroInsight
|
|
6
|
+
module Services
|
|
7
|
+
class ChineseAstrologyService
|
|
8
|
+
def initialize(client)
|
|
9
|
+
@client = client
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_zodiac(birth_details)
|
|
13
|
+
payload = birth_details.respond_to?(:to_h) ? birth_details.to_h : birth_details
|
|
14
|
+
@client.post("/chinese/zodiac", payload)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_detailed_zodiac(birth_details)
|
|
18
|
+
payload = birth_details.respond_to?(:to_h) ? birth_details.to_h : birth_details
|
|
19
|
+
@client.post("/chinese/zodiac/detailed", payload)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get_compatibility(payload)
|
|
23
|
+
@client.post("/chinese/zodiac/compatibility", payload)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_compatibility_by_sign(sign_key, payload = {})
|
|
27
|
+
@client.post("/chinese/zodiac/compatibility/#{CGI.escape(sign_key)}", payload)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_compatibility_report(your_sign_key, partner_sign_key, payload = {})
|
|
31
|
+
@client.post("/chinese/zodiac/compatibility/#{CGI.escape(your_sign_key)}/#{CGI.escape(partner_sign_key)}", payload)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AstroInsight
|
|
4
|
+
module Services
|
|
5
|
+
class GeoService
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def search_place(place)
|
|
11
|
+
@client.post("/geo/search", { keyword: place })
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_timezone_by_timezone_id(timezone_id)
|
|
15
|
+
@client.post("/geo/timezone", { timezone_id: timezone_id })
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_timezone_by_lat_lon(lat, lon)
|
|
19
|
+
@client.post("/geo/timezone-with-lat-lon", { lat: lat, lon: lon })
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
module AstroInsight
|
|
6
|
+
module Services
|
|
7
|
+
class HoroscopeService
|
|
8
|
+
def initialize(client)
|
|
9
|
+
@client = client
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_daily_horoscope(sun_sign)
|
|
13
|
+
@client.post("/horoscope/daily/#{CGI.escape(sun_sign.downcase)}")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get_detailed_daily_horoscope(sun_sign)
|
|
17
|
+
@client.post("/horoscope/daily/#{CGI.escape(sun_sign.downcase)}/detailed")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def get_tomorrow_daily_horoscope(sun_sign)
|
|
21
|
+
@client.post("/horoscope/daily/#{CGI.escape(sun_sign.downcase)}/tomorrow")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_yesterday_daily_horoscope(sun_sign)
|
|
25
|
+
@client.post("/horoscope/daily/#{CGI.escape(sun_sign.downcase)}/yesterday")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_monthly_horoscope(sun_sign)
|
|
29
|
+
@client.post("/horoscope/monthly/#{CGI.escape(sun_sign.downcase)}")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_detailed_monthly_horoscope(sun_sign)
|
|
33
|
+
@client.post("/horoscope/monthly/#{CGI.escape(sun_sign.downcase)}/detailed")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AstroInsight
|
|
4
|
+
module Services
|
|
5
|
+
class TarotService
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_one_card_reading(payload = {})
|
|
11
|
+
@client.post("/tarot/one-card", payload)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_three_card_reading(payload = {})
|
|
15
|
+
@client.post("/tarot/three-card", payload)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_celtic_cross_reading(payload = {})
|
|
19
|
+
@client.post("/tarot/celtic-cross", payload)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get_health_reading(payload = {})
|
|
23
|
+
@client.post("/tarot/health", payload)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_career_reading(payload = {})
|
|
27
|
+
@client.post("/tarot/career", payload)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_finance_reading(payload = {})
|
|
31
|
+
@client.post("/tarot/finance", payload)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_true_love_reading(payload = {})
|
|
35
|
+
@client.post("/tarot/true-love", payload)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_victory_reading(payload = {})
|
|
39
|
+
@client.post("/tarot/victory", payload)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def get_spiritual_reading(payload = {})
|
|
43
|
+
@client.post("/tarot/spiritual", payload)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def get_yes_no_reading(payload = {})
|
|
47
|
+
@client.post("/tarot/yes-no", payload)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
module AstroInsight
|
|
6
|
+
module Services
|
|
7
|
+
module Vedic
|
|
8
|
+
class AshtakvargaService
|
|
9
|
+
def initialize(client)
|
|
10
|
+
@client = client
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_planet_ashtak(ashtak_planet_key, birth_details)
|
|
14
|
+
payload = birth_details.respond_to?(:to_h) ? birth_details.to_h : birth_details
|
|
15
|
+
@client.post("/ashtakvarga/planetashtak/#{CGI.escape(ashtak_planet_key.downcase)}", payload)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_sarvashtakvarga(birth_details)
|
|
19
|
+
payload = birth_details.respond_to?(:to_h) ? birth_details.to_h : birth_details
|
|
20
|
+
@client.post("/ashtakvarga/sarvashtak", payload)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|