fastlane-plugin-sharethemeal 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a7a139663d918c4f0f935249f963a9ad68f61f3
4
- data.tar.gz: bb1edf3be1eef0386bd4e246e1574e3ef8c7d8b3
3
+ metadata.gz: cfd90e4b0150beae06a85d91a82d073e3538e29f
4
+ data.tar.gz: f22da2ae289c5234ebd4d266f728bd4bab8d3f95
5
5
  SHA512:
6
- metadata.gz: faf05aca952f0aa3f63700616aadd0f9710f6a06c46a397a2aa691cdf007b74f9aa5bf0e1474ecbfdd364886870e2da5205459484931f25317b3d9a92c6fbfcd
7
- data.tar.gz: dd74c0fe67a012d1e219f41ec73f76347f4a6ed898faaedea0d593e312975886a0cff25803578895a91ec5dcbaa25c6ee831cf619fce2739256355610eacd49c
6
+ metadata.gz: d9263897e5644c68bef4a5fb3bcd2dfac731f40e5ae0a757266235f2b1d8074be7e400bebca06e26727a500bb0a073a01b06b9103641eedfcc5def205feee65a
7
+ data.tar.gz: 0af9423ad1acc4df65aef1c03c632dfc8aee682a0d80962dc42677e3e6c23d88bf2ef573b47a30037e87ec8e2d0a51838c3a73f3959d93442d7aceaf805d9143
data/README.md CHANGED
@@ -2,34 +2,32 @@
2
2
 
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-sharethemeal)
4
4
 
5
-
6
-
7
5
  ## About sharethemeal
8
6
 
9
- ShareTheMeal
7
+ [fastlane](https://fastlane.tools) saves us hours of work, which eventually saves us a lot of money.
8
+ This is my way of reminding myself to give, on every deploy using [fastlane](https://fastlane.tools).
9
+
10
+ Opens a Browser with the Donation page of [ShareTheMeal](https://sharethemeal.org/)
11
+ to get the URL, please donate once per app - and copy the URL.
10
12
 
11
- Fastlanes saves as hours of work, wich eventually saves us alot of money.
12
- this is my try to remind myself to give, on every deploy using fastlane.
13
+ ![Screenshot](screen.png)
13
14
 
14
- Opens a Browser with the Payment page of sharethemeal
15
15
 
16
- to get the parameter values, please donate once per app - and extract the values from the URL.
17
16
 
18
- > As it is not API driven, it does not work on CI
17
+ **Help trying to Automate donation -> see issue [#5](https://github.com/hjanuschka/fastlane-plugin-sharethemeal/issues/5) for current progress**
19
18
 
19
+ Download the Apps:
20
+ * IOS: [AppStore](https://click.google-analytics.com/redirect?tid=UA-58737077-1&url=https%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fsharethemeal%2Fid977130010&aid=org.sharethemeal.app&idfa=%{idfa}&cs=stmwebsite&cm=website&cn=permanent)
21
+ * ANDROID: [PlayStore] (https://play.google.com/store/apps/details?id=org.sharethemeal.app&referrer=utm_source%3Dstmwebsite%26utm_medium%3Dwebsite%26utm_campaign%3Dpermanent)
20
22
 
21
23
 
22
24
  ## Example
23
25
 
24
26
  ```ruby
25
- sharethemeal(
26
- amount: "0.4",
27
- userhash: "xxxxx",
28
- language: "de",
29
- beneficiaryUri: "xxxxx",
30
- beneficiarySource: "contentful",
31
- thankYouUri: "xxxxxx"
32
- )
27
+ sharethemeal(
28
+ amount: "0.4",
29
+ url: "https://sharethemeal.org/de/checkout.html?userhash=xxxxxx&lang=de&currency=EUR&symbol=€&amount=0.4&version=2&beneficiaryUri=xxx&beneficiarySource=contentful&thankYouUri=xxx"
30
+ )
33
31
  ```
34
32
 
35
33
  ## Getting Started
@@ -1,68 +1,89 @@
1
+ require "rest-client"
2
+ require "base64"
3
+ require "json"
4
+ require "uri"
1
5
  module Fastlane
2
6
  module Actions
3
7
  class SharethemealAction < Action
4
8
  def self.run(params)
5
- stmurl = "https://sharethemeal.org/de/checkout.html?"
6
- stmurl << "userhash=#{params[:userhash]}&"
7
- stmurl << "lang=#{params[:language]}&"
8
- stmurl << "currency=EUR&"
9
- stmurl << "symbol=€&"
10
- stmurl << "amount=0.4&"
11
- stmurl << "version=2&"
12
- stmurl << "beneficiaryUri=#{params[:beneficiaryUri]}&"
13
- stmurl << "beneficiarySource=contentful&"
14
- stmurl << "thankYouUri=#{params[:thankYouUri]}"
15
-
16
- `open "#{stmurl}"`
9
+ params[:url] = params[:url].sub! '€', ''
10
+ url_parsed = URI.parse(params[:url])
11
+ stm_options = URI.decode_www_form(url_parsed.query).to_h
17
12
 
13
+ begin
14
+ bearer = "LAXQszxcmpGMWi24y0NFt00YPWGJnJOo9Ba8ijLcI1fmiKHI1PDF7KG7PGJU7KcX"
15
+ token_payload = {
16
+ "userHash" => stm_options["userhash"],
17
+ "currency" => "EUR"
18
+ }
19
+
20
+ client_token = RestClient.post("https://api.sharethemeal.org/api/payment/braintree/client-tokens", token_payload.to_json,
21
+ {
22
+ content_type: :json, accept: :json,
23
+ Authorization: "Bearer #{bearer}"
24
+ })
25
+
26
+ client_token_response = JSON.parse(client_token)
27
+
28
+ auth_reply = JSON.parse(Base64.decode64(client_token_response["clientToken"]))
29
+ finger_print = URI.encode_www_form_component(auth_reply["authorizationFingerprint"])
30
+
31
+ payment_infos = RestClient.get("https://api.braintreegateway.com/merchants/2c9spryb4hkdp2w5/client_api/v1/payment_methods?sharedCustomerIdentifierType=undefined&braintreeLibraryVersion=braintree%2Fweb%2F2.15.5&merchantAccountId=cscmaecenataeu&authorizationFingerprint=#{finger_print}&callback=")
32
+ payment_infos_json = JSON.parse(payment_infos)
33
+
34
+ transaction_payload = {
35
+ "userHash" => stm_options["userhash"],
36
+ "amount" => params[:amount],
37
+ "currency" => "EUR",
38
+ "paymentMethodNonce" => payment_infos_json["paymentMethods"].first["nonce"],
39
+ "beneficiarySource" => stm_options["beneficiarySource"],
40
+ "beneficiaryUri" => stm_options["beneficiaryUri"],
41
+ "thankYouUri" => stm_options["thankYouUri"]
42
+ }
43
+
44
+ transaction_response = RestClient.post('https://api.sharethemeal.org/api/payment/braintree/transactions', transaction_payload.to_json, {
45
+ content_type: :json, accept: :json,
46
+ "Authorization" => "Bearer #{bearer}"
47
+ })
48
+
49
+ transaction_response_json = JSON.parse(transaction_response)
50
+ if transaction_response_json["result"]["donationCreated"] == true
51
+ UI.success "Successfully Donated #{params[:amount]} to ShareTheMeal 🍔 "
52
+ else
53
+ UI.warning "Donation was not successfully accepted, maybe card is invalid or something else"
54
+ end
55
+
56
+ rescue => err
57
+ UI.error "Donation failed, be sure that you have done atleast one manual donation with a stored payment option"
58
+ end
18
59
  end
19
60
 
20
61
  def self.description
21
- "ShareTheMeal"
62
+ "Donate ShareTheMeal"
22
63
  end
23
64
 
24
65
  def self.authors
25
- ["Helmut Januschka"]
66
+ ["hjanuschka"]
26
67
  end
27
68
 
28
-
29
69
  def self.available_options
30
70
  [
31
- FastlaneCore::ConfigItem.new(key: :userhash,
32
- env_name: "SHARETHEMEAL_USERHASH",
33
- description: "ShareTheMeal UserHash",
71
+ FastlaneCore::ConfigItem.new(key: :url,
72
+ env_name: "SHARETHEMEAL_URL",
73
+ description: "ShareTheMeal URL",
34
74
  optional: false,
35
75
  type: String),
36
76
  FastlaneCore::ConfigItem.new(key: :amount,
37
77
  env_name: "SHARETHEMEAL_AMOUNT",
38
78
  description: "ShareTheMeal Amount",
39
79
  optional: false,
40
- type: String),
41
- FastlaneCore::ConfigItem.new(key: :language,
42
- env_name: "SHARETHEMEAL_LANGUAGE",
43
- description: "ShareTheMeal Language",
44
- optional: false,
45
- type: String),
46
- FastlaneCore::ConfigItem.new(key: :beneficiaryUri,
47
- env_name: "SHARETHEMEAL_BENEFICIARYURI",
48
- description: "ShareTheMeal Beneficiary Uri",
49
- optional: false,
50
- type: String),
51
- FastlaneCore::ConfigItem.new(key: :beneficiarySource,
52
- env_name: "SHARETHEMEAL_BENEFICIARYSOURCE",
53
- description: "ShareTheMeal Beneficiary Source",
54
- optional: false,
55
- type: String),
56
- FastlaneCore::ConfigItem.new(key: :thankYouUri,
57
- env_name: "SHARETHEMEAL_THANKYOUURI",
58
- description: "ShareTheMeal Thank you URI",
59
- optional: false,
60
- type: String)
80
+ type: String)
81
+
61
82
  ]
62
83
  end
63
84
 
64
85
  def self.is_supported?(platform)
65
- [:mac].include?(platform)
86
+ true
66
87
  end
67
88
  end
68
89
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Sharethemeal
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-sharethemeal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Helmut Januschka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: pry
15
29
  requirement: !ruby/object:Gem::Requirement