bloom_remit_client 0.9.0 → 0.10.0

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: 4a1c99743910d255c4afc76e7be6012bb19c99fe
4
- data.tar.gz: 71ed61a4d3f4f86e23210f6761333a91d4fb2570
3
+ metadata.gz: f83f9cc2392a434a313bd2f832be970cb4db9331
4
+ data.tar.gz: 5518052e63a07800664f9ee7b1bc88d6d3b7bb62
5
5
  SHA512:
6
- metadata.gz: 30b8224d1975a5b7107961061301bc019e03ec3899510ca672a6486be2fcedcb54997f9c86ea58c90250992ed96ee332dc7cd1facbd95155641ed01181d06641
7
- data.tar.gz: e2943a1ae53f607f718b42d7874ff3099746e87f0c8ea9ff5e283d841d54e20703b103896d29fef40d2eadb85d0341fa21bc1ecc0f162d23c69788c55e8ff81a
6
+ metadata.gz: a03d7e85200893573c6361177353f1705b5bc10625d3dc68f18d1f195761e3c1da42cc08cc1f3ef4eff41252e4568350c584cb395afd4e1e9f2c07287c9bfbf6
7
+ data.tar.gz: a4813146dc00b679147ea44cc613d826a09bd45ccf3508939ede39c07f35adf750d2d7ba2e3a863cd659622bbd9472f6ee8f7e3eaf85ed070f052bb73ddcb3ff
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [0.10.0] - 2016-09-30
6
+ ### Added
7
+ - Expose `category` on DepositStrategy
8
+ - `#calculate_remittance` to get the remittance fees
9
+
5
10
  ## [0.9.0] - 2016-09-16
6
11
  ### Added
7
12
  - Factory `bloom_remit_client_deposit_strategy`
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "rake", "~> 10.0"
36
36
  spec.add_development_dependency "rspec", "~> 3.0"
37
37
  spec.add_development_dependency "vcr"
38
+ spec.add_development_dependency 'faker'
38
39
  spec.add_development_dependency "webmock"
39
40
  spec.add_development_dependency "dotenv"
40
41
  spec.add_development_dependency "shoulda-matchers"
@@ -11,7 +11,7 @@ module BloomRemitClient
11
11
  attribute :sandbox, Boolean, default: true
12
12
 
13
13
  validates :host, presence: true
14
- validates :sandbox, inclusion: {in: [true, false]}
14
+ validates :sandbox, inclusion: { in: [true, false] }
15
15
 
16
16
  # GET
17
17
  # /api/v1/partners/:api_token/credits
@@ -93,6 +93,13 @@ module BloomRemitClient
93
93
  Responses::Remittances::Create.new(raw_response: raw_response)
94
94
  end
95
95
 
96
+ def calculate_remittance(calculate_params={})
97
+ params = access_params.merge(calculate_params)
98
+ request = Requests::Remittances::Calculate.new(params)
99
+ raw_response = request.call!
100
+ Responses::Remittances::Calculate.new(raw_response: raw_response)
101
+ end
102
+
96
103
  def deposit_strategies_list
97
104
  request_params = access_params
98
105
  request = Requests::DepositStrategies::List.new(request_params)
@@ -15,6 +15,7 @@ FactoryGirl.define do
15
15
  }) do
16
16
  sequence(:slug) {|n| "deposit_strategy_#{n}" }
17
17
  name "Deposit Strategy"
18
+ category "bank"
18
19
  end
19
20
 
20
21
  factory(:bloom_remit_client_responses_payments_create, {
@@ -4,6 +4,7 @@ module BloomRemitClient
4
4
  include Virtus.model
5
5
  attribute :slug, String
6
6
  attribute :name, String
7
+ attribute :category, String
7
8
 
8
9
  end
9
10
  end
@@ -8,11 +8,11 @@ module BloomRemitClient
8
8
  validates :host, presence: true
9
9
 
10
10
  def call
11
- RequestsSender.new(params).()
11
+ RequestsSender.call(params)
12
12
  end
13
13
 
14
14
  def call!
15
- fail(ArgumentError, self.errors.full_messages) if self.invalid?
15
+ raise(ArgumentError, errors.full_messages) if invalid?
16
16
  call
17
17
  end
18
18
 
@@ -0,0 +1,33 @@
1
+ module BloomRemitClient
2
+ module Requests
3
+ module Remittances
4
+ class Calculate < Base
5
+
6
+ include Concerns::HasBaseAuthentification
7
+
8
+ PATH = "/api/v1//partners/:api_token/remittances/calculate.json"
9
+
10
+ attribute :origin_amount, Float
11
+ attribute :origin_currency, String
12
+ attribute :destination_amount, Float
13
+ attribute :destination_currency, String
14
+ attribute :payout_method, String
15
+
16
+ private
17
+
18
+ def path
19
+ PATH.gsub(":api_token", self.api_token)
20
+ end
21
+
22
+ def type
23
+ POST
24
+ end
25
+
26
+ def body_params
27
+ attributes
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,21 +1,20 @@
1
+ # frozen_string_literal: true
1
2
  module BloomRemitClient
2
3
  module Requests
3
4
  module Remittances
4
5
  class Create < Base
5
-
6
6
  include Concerns::HasBaseAuthentification
7
-
8
- PATH = "/api/v1//partners/:api_token/senders/:sender_id/remittances.json"
7
+ PATH = '/api/v1/partners/:api_token/senders/:sender_id/remittances'
9
8
 
10
9
  attribute :remittance, Hash
11
10
  attribute :sender_id, String
12
11
  attribute :recipient_id, String
12
+ attribute :agent_id, String
13
13
 
14
14
  private
15
15
 
16
16
  def path
17
- PATH.gsub(":api_token", self.api_token).
18
- gsub(":sender_id", self.sender_id)
17
+ Requests.normalize_path(PATH, attributes.slice(:api_token, :sender_id))
19
18
  end
20
19
 
21
20
  def type
@@ -23,9 +22,8 @@ module BloomRemitClient
23
22
  end
24
23
 
25
24
  def body_params
26
- attributes.slice(*%i[recipient_id remittance])
25
+ attributes.slice(:agent_id, :recipient_id, :remittance)
27
26
  end
28
-
29
27
  end
30
28
  end
31
29
  end
@@ -2,23 +2,31 @@
2
2
  module BloomRemitClient
3
3
  module Requests
4
4
  class RequestsSender
5
+ class << self
6
+ def default_headers
7
+ @default_headers ||= {
8
+ 'Content-Type' => Requests::CONTENT_TYPE_JSON_UTF8,
9
+ 'Accept' => Requests::CONTENT_TYPE_JSON
10
+ }
11
+ end
12
+
13
+ def call(params)
14
+ new(params).call
15
+ end
16
+ end
17
+
5
18
  include Virtus.model
6
19
  include ActiveModel::Validations
7
20
 
8
21
  attribute :type, String
9
22
  attribute :body, String
10
- attribute :headers, Hash, lazy: true, default: ->(object, attribute) { RequestsSender.default_headers }
23
+ attribute :headers, Hash,
24
+ lazy: true,
25
+ default: ->(object, _) { object.class.default_headers }
11
26
  attribute :url, Requests::UrlBuilder
12
27
 
13
28
  validates :type, presence: true, inclusion: Requests::REQUEST_TYPES
14
29
 
15
- def self.default_headers
16
- @default_headers ||= {
17
- 'Content-Type' => Requests::CONTENT_TYPE_JSON_UTF8,
18
- 'Accept' => Requests::CONTENT_TYPE_JSON
19
- }
20
- end
21
-
22
30
  def call
23
31
  HTTParty.send(type, url.(), body: body, headers: headers)
24
32
  end
@@ -0,0 +1,69 @@
1
+ module BloomRemitClient
2
+ module Responses
3
+ module Remittances
4
+ class Calculate < Base
5
+
6
+ attribute(:origin_amount, Float, {
7
+ lazy: true,
8
+ default: :default_origin_amount,
9
+ })
10
+ attribute(:origin_currency, String, {
11
+ lazy: true,
12
+ default: :default_origin_currency,
13
+ })
14
+ attribute(:destination_amount, Float, {
15
+ lazy: true,
16
+ default: :default_destination_amount,
17
+ })
18
+ attribute(:destination_currency, String, {
19
+ lazy: true,
20
+ default: :default_destination_currency,
21
+ })
22
+ attribute(:flat_fee_in_orig_currency, Float, {
23
+ lazy: true,
24
+ default: :default_flat_fee_in_orig_currency,
25
+ })
26
+ attribute(:forex_fee_in_orig_currency, Float, {
27
+ lazy: true,
28
+ default: :default_forex_fee_in_orig_currency,
29
+ })
30
+ attribute(:payout_fee_in_orig_currency, Float, {
31
+ lazy: true,
32
+ default: :default_payout_fee_in_orig_currency,
33
+ })
34
+ attribute(:flat_fee_in_dest_currency, Float, {
35
+ lazy: true,
36
+ default: :default_flat_fee_in_dest_currency,
37
+ })
38
+ attribute(:payout_fee_in_dest_currency, Float, {
39
+ lazy: true,
40
+ default: :default_payout_fee_in_dest_currency,
41
+ })
42
+ attribute(:forex_fee_in_dest_currency, Float, {
43
+ lazy: true,
44
+ default: :default_forex_fee_in_dest_currency,
45
+ })
46
+
47
+ private
48
+
49
+ %i[
50
+ origin_amount
51
+ origin_currency
52
+ destination_amount
53
+ destination_currency
54
+ flat_fee_in_orig_currency
55
+ forex_fee_in_orig_currency
56
+ payout_fee_in_orig_currency
57
+ flat_fee_in_dest_currency
58
+ payout_fee_in_dest_currency
59
+ forex_fee_in_dest_currency
60
+ ].each do |var|
61
+ define_method :"default_#{var}" do
62
+ body[:response][var]
63
+ end
64
+ end
65
+
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,3 +1,3 @@
1
1
  module BloomRemitClient
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -29,6 +29,7 @@ require "bloom_remit_client/requests/senders/create"
29
29
  require "bloom_remit_client/requests/payments/create"
30
30
  require "bloom_remit_client/requests/remittances/create"
31
31
  require "bloom_remit_client/requests/recipients/create"
32
+ require "bloom_remit_client/requests/remittances/calculate"
32
33
  require "bloom_remit_client/responses/base"
33
34
  require "bloom_remit_client/responses/billers/list"
34
35
  require "bloom_remit_client/responses/deposit_strategies/list"
@@ -36,6 +37,7 @@ require "bloom_remit_client/responses/senders/create"
36
37
  require "bloom_remit_client/responses/payments/create"
37
38
  require "bloom_remit_client/responses/remittances/create"
38
39
  require "bloom_remit_client/responses/recipients/create"
40
+ require "bloom_remit_client/responses/remittances/calculate"
39
41
 
40
42
  module BloomRemitClient
41
43
  PRODUCTION = 'api.bloom.solutions'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloom_remit_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-16 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: faker
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: webmock
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -208,6 +222,7 @@ files:
208
222
  - lib/bloom_remit_client/requests/payments/create.rb
209
223
  - lib/bloom_remit_client/requests/rate/show.rb
210
224
  - lib/bloom_remit_client/requests/recipients/create.rb
225
+ - lib/bloom_remit_client/requests/remittances/calculate.rb
211
226
  - lib/bloom_remit_client/requests/remittances/create.rb
212
227
  - lib/bloom_remit_client/requests/requests_sender.rb
213
228
  - lib/bloom_remit_client/requests/senders/create.rb
@@ -217,6 +232,7 @@ files:
217
232
  - lib/bloom_remit_client/responses/deposit_strategies/list.rb
218
233
  - lib/bloom_remit_client/responses/payments/create.rb
219
234
  - lib/bloom_remit_client/responses/recipients/create.rb
235
+ - lib/bloom_remit_client/responses/remittances/calculate.rb
220
236
  - lib/bloom_remit_client/responses/remittances/create.rb
221
237
  - lib/bloom_remit_client/responses/senders/create.rb
222
238
  - lib/bloom_remit_client/version.rb