bloom_remit_client 0.13.0 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/push.yml +27 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +27 -0
- data/Gemfile +2 -1
- data/README.md +61 -0
- data/bloom_remit_client.gemspec +5 -5
- data/lib/bloom_remit_client.rb +40 -50
- data/lib/bloom_remit_client/client.rb +6 -133
- data/lib/bloom_remit_client/factories.rb +23 -0
- data/lib/bloom_remit_client/models/txn.rb +39 -0
- data/lib/bloom_remit_client/models/txn_preview.rb +15 -0
- data/lib/bloom_remit_client/requests/base_request.rb +18 -0
- data/lib/bloom_remit_client/requests/create_txn_preview_request.rb +24 -0
- data/lib/bloom_remit_client/requests/create_txn_request.rb +79 -0
- data/lib/bloom_remit_client/responses/base_response.rb +18 -0
- data/lib/bloom_remit_client/responses/create_txn_preview_response.rb +16 -0
- data/lib/bloom_remit_client/responses/create_txn_response.rb +11 -0
- data/lib/bloom_remit_client/version.rb +1 -1
- metadata +23 -50
- data/.travis.yml +0 -9
- data/lib/bloom_remit_client/coercers/path.rb +0 -11
- data/lib/bloom_remit_client/concerns/has_base_authentification.rb +0 -16
- data/lib/bloom_remit_client/models/biller.rb +0 -16
- data/lib/bloom_remit_client/models/credit.rb +0 -12
- data/lib/bloom_remit_client/models/deposit_strategy.rb +0 -11
- data/lib/bloom_remit_client/models/payment.rb +0 -23
- data/lib/bloom_remit_client/models/recipient.rb +0 -18
- data/lib/bloom_remit_client/models/remittance.rb +0 -22
- data/lib/bloom_remit_client/models/user.rb +0 -21
- data/lib/bloom_remit_client/requests/base.rb +0 -55
- data/lib/bloom_remit_client/requests/billers/list.rb +0 -23
- data/lib/bloom_remit_client/requests/credit/history.rb +0 -20
- data/lib/bloom_remit_client/requests/credit/list.rb +0 -20
- data/lib/bloom_remit_client/requests/deposit_strategies/list.rb +0 -21
- data/lib/bloom_remit_client/requests/payments/create.rb +0 -31
- data/lib/bloom_remit_client/requests/rate/show.rb +0 -29
- data/lib/bloom_remit_client/requests/recipients/create.rb +0 -32
- data/lib/bloom_remit_client/requests/recipients/list.rb +0 -34
- data/lib/bloom_remit_client/requests/remittances/calculate.rb +0 -33
- data/lib/bloom_remit_client/requests/remittances/create.rb +0 -30
- data/lib/bloom_remit_client/requests/requests_sender.rb +0 -35
- data/lib/bloom_remit_client/requests/senders/create.rb +0 -30
- data/lib/bloom_remit_client/requests/txns/create.rb +0 -30
- data/lib/bloom_remit_client/requests/url_builder.rb +0 -51
- data/lib/bloom_remit_client/responses/base.rb +0 -31
- data/lib/bloom_remit_client/responses/billers/list.rb +0 -17
- data/lib/bloom_remit_client/responses/deposit_strategies/list.rb +0 -20
- data/lib/bloom_remit_client/responses/payments/create.rb +0 -17
- data/lib/bloom_remit_client/responses/recipients/create.rb +0 -20
- data/lib/bloom_remit_client/responses/recipients/list.rb +0 -20
- data/lib/bloom_remit_client/responses/remittances/calculate.rb +0 -69
- data/lib/bloom_remit_client/responses/remittances/create.rb +0 -20
- data/lib/bloom_remit_client/responses/senders/create.rb +0 -21
- data/lib/bloom_remit_client/responses/txns/create.rb +0 -20
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module BloomRemitClient
|
3
|
-
module Requests
|
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
|
-
|
18
|
-
include Virtus.model
|
19
|
-
include ActiveModel::Validations
|
20
|
-
|
21
|
-
attribute :type, String
|
22
|
-
attribute :body, String
|
23
|
-
attribute :headers, Hash,
|
24
|
-
lazy: true,
|
25
|
-
default: ->(object, _) { object.class.default_headers }
|
26
|
-
attribute :url, Requests::UrlBuilder
|
27
|
-
|
28
|
-
validates :type, presence: true, inclusion: Requests::REQUEST_TYPES
|
29
|
-
|
30
|
-
def call
|
31
|
-
HTTParty.send(type, url.(), body: body, headers: headers)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Requests
|
3
|
-
module Senders
|
4
|
-
class Create < Base
|
5
|
-
|
6
|
-
include Concerns::HasBaseAuthentification
|
7
|
-
|
8
|
-
PATH = "/api/v1/partners/:token/senders.json"
|
9
|
-
|
10
|
-
attribute :sender, Hash
|
11
|
-
attribute :agent_id, String
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def path
|
16
|
-
PATH.gsub(":token", self.api_token)
|
17
|
-
end
|
18
|
-
|
19
|
-
def type
|
20
|
-
POST
|
21
|
-
end
|
22
|
-
|
23
|
-
def body_params
|
24
|
-
attributes.slice(:agent_id, :sender)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module BloomRemitClient
|
3
|
-
module Requests
|
4
|
-
module Txns
|
5
|
-
class Create < Base
|
6
|
-
include Concerns::HasBaseAuthentification
|
7
|
-
PATH = "/api/v3/txns"
|
8
|
-
|
9
|
-
attribute :txn, Hash
|
10
|
-
attribute :sender_id, String
|
11
|
-
attribute :recipient_id, String
|
12
|
-
attribute :agent_id, String
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def path
|
17
|
-
Requests.normalize_path(PATH, attributes.slice(:api_token, :sender_id))
|
18
|
-
end
|
19
|
-
|
20
|
-
def type
|
21
|
-
POST
|
22
|
-
end
|
23
|
-
|
24
|
-
def body_params
|
25
|
-
attributes.slice(*%i[api_token agent_id recipient_id sender_id txn])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module BloomRemitClient
|
3
|
-
module Requests
|
4
|
-
class UrlBuilder
|
5
|
-
require 'addressable/uri'
|
6
|
-
include Virtus.model
|
7
|
-
include ActiveModel::Validations
|
8
|
-
|
9
|
-
attribute :scheme, String, default: 'https'
|
10
|
-
attribute :subdomain, String
|
11
|
-
attribute :userinfo, String
|
12
|
-
attribute :path, Coercers::Path
|
13
|
-
attribute :host, String
|
14
|
-
attribute :port, Integer
|
15
|
-
attribute :query, String
|
16
|
-
attribute :query_params, Hash, default: {}
|
17
|
-
attribute :fragment, String
|
18
|
-
|
19
|
-
validates :path, :host, :scheme, presence: true
|
20
|
-
validates :scheme, inclusion: ['https', 'http']
|
21
|
-
|
22
|
-
def call
|
23
|
-
builder.build(to_h).to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
def host
|
27
|
-
return super unless subdomain.present?
|
28
|
-
"#{subdomain}.#{super}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def query
|
32
|
-
super || build_query
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def builder
|
38
|
-
case scheme
|
39
|
-
when 'http'
|
40
|
-
URI::HTTP
|
41
|
-
when 'https'
|
42
|
-
URI::HTTPS
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def build_query
|
47
|
-
Addressable::URI.new(query_values: query_params).query
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
class Base
|
4
|
-
|
5
|
-
include Virtus.model
|
6
|
-
attribute :raw_response, Object
|
7
|
-
attribute(:body, Coercers::IndifferentHash, {
|
8
|
-
lazy: true,
|
9
|
-
default: :default_body,
|
10
|
-
})
|
11
|
-
attribute :success, Boolean, lazy: true, default: :default_success
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def default_success
|
16
|
-
raw_response.success?
|
17
|
-
end
|
18
|
-
|
19
|
-
def default_body
|
20
|
-
json = JSON.parse(raw_response.body)
|
21
|
-
|
22
|
-
if json.is_a?(Array)
|
23
|
-
json.map(&:with_indifferent_access)
|
24
|
-
else
|
25
|
-
json.with_indifferent_access
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module Billers
|
4
|
-
class List < Base
|
5
|
-
|
6
|
-
attribute :billers, Array, lazy: true, default: :default_billers
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def default_billers
|
11
|
-
body.map { |hash| Biller.new(hash) }
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module DepositStrategies
|
4
|
-
class List < Base
|
5
|
-
|
6
|
-
attribute(:deposit_strategies, Array, {
|
7
|
-
lazy: true,
|
8
|
-
default: :default_deposit_strategies,
|
9
|
-
})
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_deposit_strategies
|
14
|
-
body.map { |hash| DepositStrategy.new(hash) }
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module Payments
|
4
|
-
class Create < Base
|
5
|
-
|
6
|
-
attribute :payment, Object, lazy: true, default: :default_payment
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def default_payment
|
11
|
-
Payment.new(body[:payment])
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module Recipients
|
4
|
-
class Create < Base
|
5
|
-
|
6
|
-
attribute(:recipient, Object, {
|
7
|
-
lazy: true,
|
8
|
-
default: :default_recipient,
|
9
|
-
})
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_recipient
|
14
|
-
Recipient.new(body[:recipient])
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module Recipients
|
4
|
-
class List < Base
|
5
|
-
|
6
|
-
attribute(:recipients, Array, {
|
7
|
-
lazy: true,
|
8
|
-
default: :default_recipients,
|
9
|
-
})
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_recipients
|
14
|
-
body.map { |hash| Recipient.new(hash) }
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,69 +0,0 @@
|
|
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,20 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module Remittances
|
4
|
-
class Create < Base
|
5
|
-
|
6
|
-
attribute(:remittance, Object, {
|
7
|
-
lazy: true,
|
8
|
-
default: :default_remittance,
|
9
|
-
})
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_remittance
|
14
|
-
Remittance.new(body[:remittance])
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module Senders
|
4
|
-
class Create < Base
|
5
|
-
|
6
|
-
attribute :sender, Object, lazy: true, default: :default_sender
|
7
|
-
|
8
|
-
def success?
|
9
|
-
raw_response.success?
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def default_sender
|
15
|
-
User.new(body[:sender])
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module BloomRemitClient
|
2
|
-
module Responses
|
3
|
-
module Txns
|
4
|
-
class Create < Base
|
5
|
-
|
6
|
-
attribute(:txn, Object, {
|
7
|
-
lazy: true,
|
8
|
-
default: :default_txn,
|
9
|
-
})
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def default_txn
|
14
|
-
Remittance.new(body[:txn])
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|