bloom_remit_client 0.11.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/push.yml +27 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +30 -0
  5. data/Gemfile +2 -1
  6. data/README.md +61 -0
  7. data/bloom_remit_client.gemspec +5 -5
  8. data/lib/bloom_remit_client.rb +43 -49
  9. data/lib/bloom_remit_client/client.rb +6 -115
  10. data/lib/bloom_remit_client/factories.rb +23 -0
  11. data/lib/bloom_remit_client/models/txn.rb +39 -0
  12. data/lib/bloom_remit_client/models/txn_preview.rb +15 -0
  13. data/lib/bloom_remit_client/requests/base_request.rb +18 -0
  14. data/lib/bloom_remit_client/requests/create_txn_preview_request.rb +24 -0
  15. data/lib/bloom_remit_client/requests/create_txn_request.rb +79 -0
  16. data/lib/bloom_remit_client/responses/base_response.rb +18 -0
  17. data/lib/bloom_remit_client/responses/create_txn_preview_response.rb +16 -0
  18. data/lib/bloom_remit_client/responses/create_txn_response.rb +11 -0
  19. data/lib/bloom_remit_client/version.rb +1 -1
  20. metadata +23 -46
  21. data/.travis.yml +0 -9
  22. data/lib/bloom_remit_client/coercers/path.rb +0 -11
  23. data/lib/bloom_remit_client/concerns/has_base_authentification.rb +0 -16
  24. data/lib/bloom_remit_client/models/biller.rb +0 -16
  25. data/lib/bloom_remit_client/models/credit.rb +0 -12
  26. data/lib/bloom_remit_client/models/deposit_strategy.rb +0 -11
  27. data/lib/bloom_remit_client/models/payment.rb +0 -23
  28. data/lib/bloom_remit_client/models/recipient.rb +0 -17
  29. data/lib/bloom_remit_client/models/remittance.rb +0 -22
  30. data/lib/bloom_remit_client/models/user.rb +0 -21
  31. data/lib/bloom_remit_client/requests/base.rb +0 -55
  32. data/lib/bloom_remit_client/requests/billers/list.rb +0 -23
  33. data/lib/bloom_remit_client/requests/credit/history.rb +0 -20
  34. data/lib/bloom_remit_client/requests/credit/list.rb +0 -20
  35. data/lib/bloom_remit_client/requests/deposit_strategies/list.rb +0 -21
  36. data/lib/bloom_remit_client/requests/payments/create.rb +0 -31
  37. data/lib/bloom_remit_client/requests/rate/show.rb +0 -29
  38. data/lib/bloom_remit_client/requests/recipients/create.rb +0 -32
  39. data/lib/bloom_remit_client/requests/remittances/calculate.rb +0 -33
  40. data/lib/bloom_remit_client/requests/remittances/create.rb +0 -30
  41. data/lib/bloom_remit_client/requests/requests_sender.rb +0 -35
  42. data/lib/bloom_remit_client/requests/senders/create.rb +0 -29
  43. data/lib/bloom_remit_client/requests/url_builder.rb +0 -51
  44. data/lib/bloom_remit_client/responses/base.rb +0 -31
  45. data/lib/bloom_remit_client/responses/billers/list.rb +0 -17
  46. data/lib/bloom_remit_client/responses/deposit_strategies/list.rb +0 -20
  47. data/lib/bloom_remit_client/responses/payments/create.rb +0 -17
  48. data/lib/bloom_remit_client/responses/recipients/create.rb +0 -20
  49. data/lib/bloom_remit_client/responses/remittances/calculate.rb +0 -69
  50. data/lib/bloom_remit_client/responses/remittances/create.rb +0 -20
  51. data/lib/bloom_remit_client/responses/senders/create.rb +0 -21
@@ -1,29 +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
-
12
- private
13
-
14
- def path
15
- PATH.gsub(":token", self.api_token)
16
- end
17
-
18
- def type
19
- POST
20
- end
21
-
22
- def body_params
23
- { sender: sender }
24
- end
25
-
26
- end
27
- end
28
- end
29
- 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,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