altadata 0.0.1 → 0.0.2
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 +4 -4
- data/lib/altadata/client.rb +27 -1
- data/lib/altadata/version.rb +1 -1
- data/spec/altadata_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4038d966cc01b808509c51bbd99c11efb44a6a88656df0b6638c35ac7697975a
|
4
|
+
data.tar.gz: 5dc00fd520c51880c7501bd764c138919d4dc7289999536381353ccc8c48cc0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55efddb449da59699cc841ffd3b90a443fde140e1473e58a2d42c91b0d5acc69685b55ba4e91f86daf8dffc3b14b261de612e8a2aaced87edb95fdf61a70c2ad
|
7
|
+
data.tar.gz: 4c29575a0bf0d2bb30f7a6e10c6dd5bfab4b1effea120248f318a1192267d19a59f4b2d546b06fbf37d6021f72a1e87729be692b7dd63ab0a80e64583b8214aa
|
data/lib/altadata/client.rb
CHANGED
@@ -15,11 +15,37 @@ module Altadata
|
|
15
15
|
@subscription_api_url = "https://www.altadata.io/subscription/api/subscriptions?api_key=#{@api_key}"
|
16
16
|
end
|
17
17
|
|
18
|
+
##
|
19
|
+
# Converts subscription api response to unnested version
|
20
|
+
def fix_subscription_response(response_json)
|
21
|
+
data = []
|
22
|
+
|
23
|
+
response_json.each do |product|
|
24
|
+
product_item = product
|
25
|
+
product_item['createdAt'] = product_item['createdAt'].gsub('T', ' ').split('+')[0]
|
26
|
+
product_item['validUntil'] = product_item['validUntil'].gsub('T', ' ').split('+')[0]
|
27
|
+
product_item['title'] = product_item['offer']['title']
|
28
|
+
product_item['code'] = product_item['offer']['code']
|
29
|
+
product_item['price'] = product_item['plan']['price']
|
30
|
+
product_item['plan_name'] = product_item['plan']['title']
|
31
|
+
product_item['period'] = product_item['plan']['period']
|
32
|
+
|
33
|
+
product_item.delete('id')
|
34
|
+
product_item.delete('offer')
|
35
|
+
product_item.delete('plan')
|
36
|
+
|
37
|
+
data << product_item
|
38
|
+
end
|
39
|
+
|
40
|
+
data
|
41
|
+
end
|
42
|
+
|
18
43
|
##
|
19
44
|
# Retrieves customer's subscription info
|
20
45
|
def list_subscription
|
21
46
|
response = Faraday.get(@subscription_api_url)
|
22
|
-
JSON.parse(response.body)
|
47
|
+
response_json = JSON.parse(response.body)
|
48
|
+
fix_subscription_response(response_json)
|
23
49
|
end
|
24
50
|
|
25
51
|
##
|
data/lib/altadata/version.rb
CHANGED
data/spec/altadata_spec.rb
CHANGED