stm_api 0.1.5 → 0.1.6
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/stm_api.rb +24 -13
- data/lib/stm_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 185a1a17b38ced9d60f51ad313e841f93ad7b837
|
4
|
+
data.tar.gz: 44db1fd5c598dba58eedea59bbb4a9b5dc6ff653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a38889fbca28842a09dbe2902cd3e9fb83911c80161e3124e24897f643db747871758887a792facc736adb35bd4a91343de03b2e0aa7d94f4ef9af431cdb0f
|
7
|
+
data.tar.gz: 28a0a313c6fa1b5aec5a91841fc4cb1cb05d2c46822aded07faca5555af90c18d0ad8c23a40a8051b452f8f7330c19386817bbb11806e2a18b77d7c7bc87efda
|
data/lib/stm_api.rb
CHANGED
@@ -11,38 +11,49 @@ module StmApi
|
|
11
11
|
attr_accessor :currency
|
12
12
|
attr_accessor :team_id
|
13
13
|
BEARER = 'LAXQszxcmpGMWi24y0NFt00YPWGJnJOo9Ba8ijLcI1fmiKHI1PDF7KG7PGJU7KcX'
|
14
|
-
|
14
|
+
|
15
15
|
def initialize(params = {})
|
16
16
|
@userhash = params[:userhash]
|
17
17
|
@currency = params[:currency]
|
18
18
|
@team_id = params[:team_id]
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
def user_info
|
21
22
|
user_info_response = RestClient.get("https://api.sharethemeal.org/api/users/#{@userhash}",
|
22
|
-
|
23
|
-
|
23
|
+
content_type: :json, accept: :json,
|
24
|
+
Authorization: "Bearer #{BEARER}")
|
25
|
+
user_info_json = JSON.parse(user_info_response)
|
26
|
+
return user_info_json
|
27
|
+
end
|
28
|
+
|
29
|
+
def statistics
|
30
|
+
user_info_response = RestClient.get("https://api.sharethemeal.org/api/campaigns/zomba/status",
|
31
|
+
content_type: :json, accept: :json,
|
32
|
+
Authorization: "Bearer #{BEARER}")
|
24
33
|
user_info_json = JSON.parse(user_info_response)
|
25
|
-
|
34
|
+
return user_info_json
|
26
35
|
end
|
27
|
-
|
36
|
+
|
37
|
+
def user_teams
|
28
38
|
team_statistic = RestClient.get("https://api.sharethemeal.org/api/users/#{@userhash}/teams",
|
29
|
-
|
30
|
-
|
39
|
+
content_type: :json, accept: :json,
|
40
|
+
Authorization: "Bearer #{BEARER}")
|
31
41
|
team_statistic_json = JSON.parse(team_statistic)
|
32
|
-
|
42
|
+
|
33
43
|
team_statistic_json["userTeams"]
|
34
44
|
end
|
45
|
+
|
35
46
|
def find_one_team(id)
|
36
47
|
teams = user_teams
|
37
|
-
teams.each do |
|
48
|
+
teams.each do |t|
|
38
49
|
if t["teamId"] == id
|
39
50
|
return t
|
40
51
|
end
|
41
52
|
end
|
42
53
|
return false
|
43
54
|
end
|
55
|
+
|
44
56
|
def donate(params = {})
|
45
|
-
|
46
57
|
token_payload = {
|
47
58
|
'userHash' => @userhash,
|
48
59
|
'currency' => @currency
|
@@ -78,8 +89,8 @@ module StmApi
|
|
78
89
|
return false
|
79
90
|
end
|
80
91
|
|
81
|
-
|
82
|
-
|
92
|
+
# rescue
|
93
|
+
# return false
|
83
94
|
end
|
84
95
|
end
|
85
96
|
end
|
data/lib/stm_api/version.rb
CHANGED