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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stm_api.rb +24 -13
  3. data/lib/stm_api/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3e0d4f0edbfce75f7205d6672cdf7d50644859a
4
- data.tar.gz: 373132c9090eee0463023b65ae8f23c060d2a2d7
3
+ metadata.gz: 185a1a17b38ced9d60f51ad313e841f93ad7b837
4
+ data.tar.gz: 44db1fd5c598dba58eedea59bbb4a9b5dc6ff653
5
5
  SHA512:
6
- metadata.gz: 46a716f26e4993f14f1a5731615bdf6cbacb7a31c7d06b1d550b0542fdf8768fe16011af15beb6d05a92ea076e4e2866e70b29d36ed001342f04c79254e23522
7
- data.tar.gz: 53cf71643caafe108154e45498ed539d77de2ebbbdc6d85f2a6b7e961a2c3a0869e78ed6ec5923a5b07c2acc6f47a45ccee3f55ef29aba53be43698c73598755
6
+ metadata.gz: f5a38889fbca28842a09dbe2902cd3e9fb83911c80161e3124e24897f643db747871758887a792facc736adb35bd4a91343de03b2e0aa7d94f4ef9af431cdb0f
7
+ data.tar.gz: 28a0a313c6fa1b5aec5a91841fc4cb1cb05d2c46822aded07faca5555af90c18d0ad8c23a40a8051b452f8f7330c19386817bbb11806e2a18b77d7c7bc87efda
@@ -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
- def user_info()
20
+
21
+ def user_info
21
22
  user_info_response = RestClient.get("https://api.sharethemeal.org/api/users/#{@userhash}",
22
- content_type: :json, accept: :json,
23
- Authorization: "Bearer #{BEARER}")
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
- def user_teams()
36
+
37
+ def user_teams
28
38
  team_statistic = RestClient.get("https://api.sharethemeal.org/api/users/#{@userhash}/teams",
29
- content_type: :json, accept: :json,
30
- Authorization: "Bearer #{BEARER}")
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 | t |
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
- #rescue
82
- # return false
92
+ # rescue
93
+ # return false
83
94
  end
84
95
  end
85
96
  end
@@ -1,3 +1,3 @@
1
1
  module StmApi
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stm_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Helmut Januschka