stm_api 0.1.7 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e09b6e1ebed6871b097a94b053fdfcfb71da21d8
4
- data.tar.gz: b2c0796b23e596a0eeefbdaf1a6aa4e785fcd736
3
+ metadata.gz: d98b7fc70a320a62ffdd6c6bf3d4dd0870a6223c
4
+ data.tar.gz: c1ae985de585c94fe91e1ffa0b4190c13d16efef
5
5
  SHA512:
6
- metadata.gz: f6b0431c4eec9c20e200b08f9c6665510cf9a2221fe5db41d359e29b74ae7cf6b64c735b7725966a856aee24df0a40b76be6253211b049af9cb1027eddfe0a76
7
- data.tar.gz: 3699614cd9147a3830fd3050b93f7f0e788554e2700c71d589916b3e6b5dac5c5f069ed40037cbfe9c0c7ba61e37d8cb52857a9f0a3e0459652088a262dd9724
6
+ metadata.gz: 3e9a3e89cd63eedaf9dc8f80efdc541bff5089cbdaf84ba218dcc3704cec18a5ee4673529fdbef6fcce6b2744469aa8db7ed8838737524ab7c95ff5e958c709a
7
+ data.tar.gz: 35cde18658adeed155de28f368b577740e7cb558252015623fa5045a638e58e17ba8dc3efcab55876f91f82ec765bcae930b6882d473d1eb4bf4f52ea1b9804a
@@ -10,12 +10,14 @@ module StmApi
10
10
  attr_accessor :userhash
11
11
  attr_accessor :currency
12
12
  attr_accessor :team_id
13
+ attr_accessor :campaign_id
13
14
  BEARER = 'LAXQszxcmpGMWi24y0NFt00YPWGJnJOo9Ba8ijLcI1fmiKHI1PDF7KG7PGJU7KcX'
14
15
 
15
16
  def initialize(params = {})
16
17
  @userhash = params[:userhash]
17
18
  @currency = params[:currency]
18
19
  @team_id = params[:team_id]
20
+ @campaign_id = campaigns.first unless params[:campaign_id]
19
21
  end
20
22
 
21
23
  def user_info
@@ -43,6 +45,18 @@ module StmApi
43
45
  team_statistic_json["userTeams"]
44
46
  end
45
47
 
48
+ def campaigns
49
+ campaigns_raw = RestClient.get("https://api.sharethemeal.org/api/meta",
50
+ content_type: :json, accept: :json,
51
+ Authorization: "Bearer #{BEARER}")
52
+ campaigns_json = JSON.parse(campaigns_raw)
53
+ found_campaigns = []
54
+ campaigns_json["campaigns"].each do |camp, v|
55
+ found_campaigns << camp
56
+ end
57
+ found_campaigns
58
+ end
59
+
46
60
  def find_one_team(id)
47
61
  teams = user_teams
48
62
  teams.each do |t|
@@ -76,7 +90,8 @@ module StmApi
76
90
  'amount' => params[:amount],
77
91
  'currency' => @currency,
78
92
  'paymentMethodNonce' => payment_infos_json['paymentMethods'].first['nonce'],
79
- 'teamId' => @team_id
93
+ 'teamId' => @team_id,
94
+ 'campaignId' => @campaign_id
80
95
  }
81
96
 
82
97
  transaction_response = RestClient.post('https://api.sharethemeal.org/api/payment/braintree/transactions', transaction_payload.to_json, content_type: :json, accept: :json,
@@ -1,3 +1,3 @@
1
1
  module StmApi
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stm_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Helmut Januschka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.6.2
151
+ rubygems_version: 2.6.8
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Donate to share the meal