bloom_remit2 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: c9fe3102c89ee58605e86339d9a9b4f642b475ffb6efa9e6dfdf4ee6480506de
4
- data.tar.gz: 7103274c649289b34227eabedd51437675f2afed4695988573b19df98c16034c
3
+ metadata.gz: 04fe85ab82a87f635a07f9b53a34834f9148dcf848d54425de8a381825def564
4
+ data.tar.gz: 49dc8fd1d1507677577aca8458f6339ca1442141bf61bc9b61d66ebd54cc12cf
5
5
  SHA512:
6
- metadata.gz: 9899e21a046843bb50059265f37d2ac9a606b87dc96122419d5c77b551bb0f0e9645368029a19cd5bdd3a5dca46f807d5c6ba609e7479c32233f576228ebc30a
7
- data.tar.gz: 06dbce27bfa38b8e5eb919ca9342899d4e79f08bb39d2de3736a6311edd2b9d1eb4dedbc5b7ecad0b5567c6f621633ec4e2a8e4876c57368580b64f899bb4f86
6
+ metadata.gz: 4706edc255e3764d4f93d2a6a7a93f488af516ccb8af74a5728711df0231b6a2692813b0969ce57d03bdb5c9386f608847927103db8dd2d5669a769800da8e70
7
+ data.tar.gz: e7de7a5fe4d1092d2cafcc56aef681eda4d0199afb1489abdbbbb3f69d2acfd88353aadc417517a8dce36697def82927ca1455f9caf3c3a6e15b46a9c6c18195
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic
6
6
  Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased]
8
+ ## 0.1.1
9
+ ### Added
10
+ - Fix BloomRemit2::Remittance.execute & add test
11
+ - Remove BloomRemit2::Remittance.calculate
12
+
13
+ ## 0.1.0
9
14
  ### Added
10
15
  - Initial release
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bloom_remit2 (0.1.0)
4
+ bloom_remit2 (0.1.1)
5
5
  activesupport
6
6
  gem_config
7
7
  httparty
data/README.md CHANGED
@@ -152,8 +152,7 @@ sender_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
152
152
  BloomRemit2::Recipient.list(sender_id)
153
153
  ```
154
154
 
155
- ### Show details about a recipient of a given user, and their associated remittance
156
- IDs
155
+ ### Show details about a recipient of a given user, and their associated remittance IDs
157
156
  ```ruby
158
157
  # GET /api/v1/partners/:api_token/senders/:sender_id/recipients/:id
159
158
 
@@ -204,7 +203,7 @@ BloomRemit2::Remittance.list(sender_id)
204
203
  ```
205
204
 
206
205
  ### Initiate a new money transfer by providing a recipient_id and a remittance hash
207
- **TODO: Need to add tests**
206
+ Use either `paid_in_orig_currency` or `receivable_in_dest_currency` and not both as this will result in a 500 Internal Server error.
208
207
  ```ruby
209
208
  # POST /api/v1/partners/:api_token/senders/:sender_id/remittances
210
209
 
@@ -221,7 +220,7 @@ BloomRemit2::Remittance.execute(
221
220
  flat_fee_in_orig_currency: 0,
222
221
  forex_margin: 0,
223
222
  orig_currency: 'PHP',
224
- paid_in_orig_currency: 0,
223
+ # paid_in_orig_currency: 0,
225
224
  payout_method: 'BPI',
226
225
  receivable_in_dest_currency: 25000
227
226
  }
@@ -254,40 +253,6 @@ BloomRemit2::Remittance.cancel(sender_id, remittance_id)
254
253
  => remittance_hash, not a BloomRemit2::Remittance
255
254
  ```
256
255
 
257
- ### Returns the total fees for a remittance amount and payout method
258
- **TODO: Needs to be implemented; this returns a 500 Internal Server error**
259
-
260
- In order to calculate the cost of a given remittance, you will need to provide
261
- an amount, a currency, and a payout_method. You may provide either the
262
- origin_amount (the money paid by the sender), or the destination_amount (the
263
- money received by the beneficiary), and the calculator will compute the fees
264
- automatically.
265
-
266
- If you provide the origin_amount, the calculator will give you the amount
267
- receivable at the destination of the remittance. If you provide the
268
- destination_amount, the calculator will give you the amount that must be paid by
269
- the sender at the point of origin.
270
- ```ruby
271
- # POST /api/v1/partners/:api_token/remittances/calculate
272
-
273
- BloomRemit2::Remittance.calculate(
274
- origin_amount: 15000,
275
- origin_currency: 'PHP',
276
- payout_method: 'BPI'
277
- )
278
-
279
- BloomRemit2::Remittance.calculate(
280
- destination_amount: 10000,
281
- destination_currency: 'PHP',
282
- payout_method: 'BPI'
283
- )
284
-
285
- BloomRemit2::Remittance.calculate(
286
- origin_amount: 125000,
287
- payout_method: 'BPI'
288
- )
289
- ```
290
-
291
256
  ## Sender uploads
292
257
 
293
258
  **TODO: Needs to be implemented**
@@ -3,20 +3,28 @@ require 'httparty'
3
3
  module BloomRemit2
4
4
  class Client
5
5
  class << self
6
- def get(path, headers = default_get_headers, query: {})
7
- HTTParty.get(url(path), { query: query, headers: headers })
6
+ def get(path, headers = default_get_headers, query: {}, staging: false)
7
+ the_url = url(path)
8
+ the_url = staging_url(path) if staging
9
+ HTTParty.get(the_url, { query: query, headers: headers })
8
10
  end
9
11
 
10
- def post(path, body = {}, headers = default_post_headers)
11
- HTTParty.post(url(path), { body: body.to_json, headers: headers })
12
+ def post(path, body = {}, staging = false, headers = default_post_headers)
13
+ the_url = url(path)
14
+ the_url = staging_url(path) if staging
15
+ HTTParty.post(the_url, { body: body.to_json, headers: headers })
12
16
  end
13
17
 
14
- def put(path, body = [], headers = default_put_headers)
15
- HTTParty.put(url(path), { body: URI.encode_www_form(body), headers: headers })
18
+ def put(path, body = [], headers = default_put_headers, staging: false)
19
+ the_url = url(path)
20
+ the_url = staging_url(path) if staging
21
+ HTTParty.put(the_url, { body: URI.encode_www_form(body), headers: headers })
16
22
  end
17
23
 
18
- def delete(path, headers = default_get_headers)
19
- HTTParty.delete(url(path), { headers: headers })
24
+ def delete(path, headers = default_get_headers, staging: false)
25
+ the_url = url(path)
26
+ the_url = staging_url(path) if staging
27
+ HTTParty.delete(the_url, { headers: headers })
20
28
  end
21
29
 
22
30
  private
@@ -25,6 +33,10 @@ module BloomRemit2
25
33
  'https://www.bloomremit.net'
26
34
  end
27
35
 
36
+ def staging_url(path)
37
+ "https://staging.bloomremit.net/#{path}"
38
+ end
39
+
28
40
  def url(path)
29
41
  "#{base_url}/#{path}"
30
42
  end
@@ -2,8 +2,38 @@ module BloomRemit2
2
2
  class Remittance
3
3
  class << self
4
4
  # Initiate a new money transfer by providing a recipient_id and remittance hash
5
- def execute(sender_id, remittance_hash)
6
- remittance = Client.post(path(sender_id))
5
+ def execute(sender_id, remittance_hash, staging: false)
6
+ result = Client.post(path(sender_id), remittance_hash, staging)
7
+ remittance = result['remittance'].with_indifferent_access
8
+ new(
9
+ remittance[:id],
10
+ remittance[:partner_id],
11
+ remittance[:orig_currency],
12
+ remittance[:dest_currency],
13
+ remittance[:paid_in_orig_currency],
14
+ remittance[:forex_margin],
15
+ remittance[:flat_fee_in_orig_currency],
16
+ remittance[:payout_method],
17
+ remittance[:status],
18
+ remittance[:account_name],
19
+ remittance[:account_number],
20
+ remittance[:teller_id],
21
+ remittance[:sender_id],
22
+ remittance[:client_external_id],
23
+ recipient: Recipient.new(
24
+ remittance[:recipient_id],
25
+ remittance[:sender_id],
26
+ nil,
27
+ nil,
28
+ nil,
29
+ nil,
30
+ nil,
31
+ nil,
32
+ nil,
33
+ nil,
34
+ nil
35
+ )
36
+ )
7
37
  end
8
38
 
9
39
  # Cancel a remittance
@@ -69,19 +99,6 @@ module BloomRemit2
69
99
  )
70
100
  end
71
101
 
72
- # TODO: Returns 500 Internal Server Error
73
- # Returns the total fees for a given remittance amount and payout method
74
- # def calculate_fees(payout_method, origin_amount: nil, origin_currency: nil, destination_amount: nil, destination_currency: nil)
75
- # remittance = Client.post(path_for_calculate, fees_hash)
76
- # end
77
-
78
- private
79
-
80
- # TODO: Uncomment when implementing .calculate_fees
81
- # def path_for_calculate
82
- # "api/v1/partners/#{BloomRemit2.configuration.api_token}/remittances/calculate"
83
- # end
84
-
85
102
  def path(sender_id)
86
103
  "api/v1/partners/#{BloomRemit2.configuration.api_token}/senders/#{sender_id}/remittances"
87
104
  end
@@ -123,9 +140,9 @@ module BloomRemit2
123
140
  @flat_fee_in_orig_currency = flat_fee_in_orig_currency
124
141
  @payout_method = payout_method
125
142
  @status = status
126
- @account_name = account_name,
127
- @account_number = account_number,
128
- @teller_id = teller_id,
143
+ @account_name = account_name
144
+ @account_number = account_number
145
+ @teller_id = teller_id
129
146
  @sender_id = sender_id
130
147
  @client_external_id = client_external_id
131
148
  @recipient = recipient
@@ -1,3 +1,3 @@
1
1
  module BloomRemit2
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloom_remit2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavi Ablaza
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-23 00:00:00.000000000 Z
11
+ date: 2020-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport