bloom_remit_client 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20c4a963e5146314391fb735dd861bc15bf6b254
4
- data.tar.gz: 178e27b940f44da53dcbead15141d770474904ca
3
+ metadata.gz: bf0cd6b7a3e7919d1cf2424a676cf5dec9a1a308
4
+ data.tar.gz: 87b7e333204589009ec8ad99c8feb823e89bd37c
5
5
  SHA512:
6
- metadata.gz: 7b71c1cadfcc4332ef758e7e2cb3ddf67bd28db68750c987d7b591b6d43512e9652edd2349e96956128a9b2b728bbb357d505218a98308edfa5024f1b0eec43d
7
- data.tar.gz: 5192c159777d5c0840443ac069bc7f49cc941f711db998f62d07ecfe3eb76f89da1f2a658311a8584f1b4e8cda42425e5404255fbad2c2332851992afd69c10c
6
+ metadata.gz: 93ba9929ce8a13d2c00c18ad37f80db1fe36b9b9e0d9b2f708236ab7da909d0633d6dba560dfe5bb07677648d99dd572514f8c41b5a1cad1b2603f65c000037e
7
+ data.tar.gz: 0d0d3d334bc5bf1d6df8861218cf81be1a1725d8b6a3612824b52caeb74aa6a33c7a5c503009d085902010c2cdded315e6da67c862893d38ec85b39a10eb352a
@@ -2,6 +2,14 @@
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.2.0] - 2016-07-29
6
+ ### Added
7
+ - Add ability to create sender
8
+ - Add ability to create payment
9
+
10
+ ### Changed
11
+ - Require `agent_id` to be set on the client
12
+
5
13
  ## [0.1.0] - 2016-07-20
6
14
  ### Added
7
15
  - Fetch billers
@@ -6,8 +6,16 @@ require 'active_support/core_ext/object/try'
6
6
  require "bloom_remit_client/version"
7
7
  require "bloom_remit_client/client"
8
8
  require "bloom_remit_client/models/biller"
9
+ require "bloom_remit_client/models/user"
10
+ require "bloom_remit_client/models/payment"
11
+ require "bloom_remit_client/requests/base_request"
9
12
  require "bloom_remit_client/requests/billers_request"
13
+ require "bloom_remit_client/requests/create_sender_request"
14
+ require "bloom_remit_client/requests/create_payment_request"
15
+ require "bloom_remit_client/responses/base_response"
10
16
  require "bloom_remit_client/responses/billers_response"
17
+ require "bloom_remit_client/responses/create_sender_response"
18
+ require "bloom_remit_client/responses/create_payment_response"
11
19
 
12
20
  module BloomRemitClient
13
21
 
@@ -1,15 +1,14 @@
1
1
  module BloomRemitClient
2
2
  class Client
3
3
 
4
- DEFAULT_URL = "https://bloom.solutions"
5
-
6
4
  include Virtus.model
7
5
  attribute :token, String
8
6
  attribute :secret, String
9
- attribute :url, String, default: DEFAULT_URL
7
+ attribute :agent_id, String
8
+ attribute :url, String
10
9
 
11
10
  include ActiveModel::Validations
12
- validates :token, :secret, presence: true
11
+ validates :token, :secret, :agent_id, :url, presence: true
13
12
 
14
13
  def billers
15
14
  request = BillersRequest.new(default_opts)
@@ -17,10 +16,24 @@ module BloomRemitClient
17
16
  BillersResponse.new(raw_response: raw_response)
18
17
  end
19
18
 
19
+ def create_sender(opts)
20
+ request = CreateSenderRequest.new(default_opts.merge(sender: opts))
21
+ raw_response = request.()
22
+ CreateSenderResponse.new(raw_response: raw_response)
23
+ end
24
+
25
+ def create_payment(opts)
26
+ params = default_opts.
27
+ merge(sender_id: opts.delete(:sender_id)).
28
+ merge(payment: opts)
29
+ request = CreatePaymentRequest.new(params)
30
+ CreatePaymentResponse.new(raw_response: request.())
31
+ end
32
+
20
33
  private
21
34
 
22
35
  def default_opts
23
- attributes.slice(:token, :secret, :url)
36
+ attributes.slice(:token, :secret, :url, :agent_id)
24
37
  end
25
38
 
26
39
  end
@@ -0,0 +1,23 @@
1
+ module BloomRemitClient
2
+ class Payment
3
+
4
+ include Virtus.model
5
+ attribute :id, String
6
+ attribute :teller_id, String
7
+ attribute :recipient_id, String
8
+ attribute :orig_currency, String
9
+ attribute :dest_currency, String
10
+ attribute :paid_in_orig_currency, Float
11
+ attribute :receivable_in_dest_currency, Float
12
+ attribute :status, String
13
+ attribute :payout_method, String
14
+ attribute :partner_id, String
15
+ attribute :flat_fee_in_orig_currency, Float
16
+ attribute :forex_margin, Float
17
+ attribute :account_name, String
18
+ attribute :account_number, String
19
+ attribute :callback_url, String
20
+ attribute :sender_id, String
21
+
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module BloomRemitClient
2
+ class User
3
+
4
+ include Virtus.model
5
+ attribute :id, String
6
+ attribute :email, String
7
+ attribute :first_name, String
8
+ attribute :last_name, String
9
+ attribute :passport_number, String
10
+ attribute :passport_expiry_date, String
11
+ attribute :tin, String
12
+ attribute :mobile, String
13
+ attribute :address, String
14
+ attribute :city, String
15
+ attribute :state, String
16
+ attribute :zip_code, String
17
+ attribute :country, String
18
+ attribute :birthdate, String
19
+
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ module BloomRemitClient
2
+ class BaseRequest
3
+
4
+ include Virtus.model
5
+ attribute :token, String
6
+ attribute :secret, String
7
+ attribute :url, String
8
+ attribute :agent_id, String
9
+ attribute :path, String, lazy: true, default: :default_path
10
+ attribute :endpoint, String, lazy: true, default: :default_endpoint
11
+
12
+ include ActiveModel::Validations
13
+ validates :token, :secret, :url, :path, presence: true
14
+
15
+ def call
16
+ HTTParty.get(self.endpoint)
17
+ end
18
+
19
+ private
20
+
21
+ def default_endpoint
22
+ return nil if self.url.nil?
23
+ uri = URI.parse(self.url)
24
+ uri.path = path
25
+ uri.to_s
26
+ end
27
+
28
+ end
29
+ end
@@ -1,28 +1,16 @@
1
1
  module BloomRemitClient
2
- class BillersRequest
2
+ class BillersRequest < BaseRequest
3
3
 
4
4
  PATH = "/api/v2/billers.json"
5
5
 
6
- include Virtus.model
7
- attribute :token, String
8
- attribute :secret, String
9
- attribute :url, String
10
- attribute :endpoint, String, lazy: true, default: :default_endpoint
11
-
12
- include ActiveModel::Validations
13
- validates :token, :secret, :url, :endpoint, presence: true
14
-
15
6
  def call
16
7
  HTTParty.get(self.endpoint)
17
8
  end
18
9
 
19
10
  private
20
11
 
21
- def default_endpoint
22
- return nil if self.url.nil?
23
- uri = URI.parse(self.url)
24
- uri.path = PATH
25
- uri.to_s
12
+ def default_path
13
+ PATH
26
14
  end
27
15
 
28
16
  end
@@ -0,0 +1,30 @@
1
+ module BloomRemitClient
2
+ class CreatePaymentRequest < BaseRequest
3
+
4
+ PATH = "/api/v2/payments.json"
5
+
6
+ attribute :payment, Hash
7
+ attribute :sender_id, String
8
+
9
+ def call
10
+ HTTParty.post(self.endpoint, body: params)
11
+ end
12
+
13
+ private
14
+
15
+ def default_path
16
+ PATH
17
+ end
18
+
19
+ def params
20
+ {
21
+ api_token: token,
22
+ api_secret: secret,
23
+ agent_id: agent_id,
24
+ sender_id: sender_id,
25
+ payment: payment,
26
+ }
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ module BloomRemitClient
2
+ class CreateSenderRequest < BaseRequest
3
+
4
+ PATH = "/api/v1/partners/:token/senders.json"
5
+
6
+ attribute :sender, Hash
7
+
8
+ def call
9
+ HTTParty.post(self.endpoint, body: params)
10
+ end
11
+
12
+ private
13
+
14
+ def default_path
15
+ PATH.gsub(":token", self.token)
16
+ end
17
+
18
+ def params
19
+ { api_secret: secret, sender: sender }
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module BloomRemitClient
2
+ class BaseResponse
3
+
4
+ include Virtus.model
5
+ attribute :raw_response, Object
6
+
7
+ private
8
+
9
+ def data
10
+ json = JSON.parse(raw_response.body)
11
+
12
+ if json.is_a?(Array)
13
+ json.map(&:with_indifferent_access)
14
+ else
15
+ json.with_indifferent_access
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -1,8 +1,6 @@
1
1
  module BloomRemitClient
2
- class BillersResponse
2
+ class BillersResponse < BaseResponse
3
3
 
4
- include Virtus.model
5
- attribute :raw_response, Object
6
4
  attribute :billers, Array, lazy: true, default: :default_billers
7
5
 
8
6
  private
@@ -11,9 +9,5 @@ module BloomRemitClient
11
9
  data.map { |hash| Biller.new(hash) }
12
10
  end
13
11
 
14
- def data
15
- JSON.parse(raw_response.body)
16
- end
17
-
18
12
  end
19
13
  end
@@ -0,0 +1,17 @@
1
+ module BloomRemitClient
2
+ class CreatePaymentResponse < BaseResponse
3
+
4
+ attribute :payment, Object, lazy: true, default: :default_payment
5
+
6
+ def success?
7
+ raw_response.success?
8
+ end
9
+
10
+ private
11
+
12
+ def default_payment
13
+ Payment.new(data[:payment])
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module BloomRemitClient
2
+ class CreateSenderResponse < BaseResponse
3
+
4
+ attribute :sender, Object, lazy: true, default: :default_sender
5
+
6
+ def success?
7
+ raw_response.success?
8
+ end
9
+
10
+ private
11
+
12
+ def default_sender
13
+ User.new(data[:sender])
14
+ end
15
+
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module BloomRemitClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.0
4
+ version: 0.2.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-07-20 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -175,8 +175,16 @@ files:
175
175
  - lib/bloom_remit_client.rb
176
176
  - lib/bloom_remit_client/client.rb
177
177
  - lib/bloom_remit_client/models/biller.rb
178
+ - lib/bloom_remit_client/models/payment.rb
179
+ - lib/bloom_remit_client/models/user.rb
180
+ - lib/bloom_remit_client/requests/base_request.rb
178
181
  - lib/bloom_remit_client/requests/billers_request.rb
182
+ - lib/bloom_remit_client/requests/create_payment_request.rb
183
+ - lib/bloom_remit_client/requests/create_sender_request.rb
184
+ - lib/bloom_remit_client/responses/base_response.rb
179
185
  - lib/bloom_remit_client/responses/billers_response.rb
186
+ - lib/bloom_remit_client/responses/create_payment_response.rb
187
+ - lib/bloom_remit_client/responses/create_sender_response.rb
180
188
  - lib/bloom_remit_client/version.rb
181
189
  homepage: https://github.com/imacchiato/bloom_remit_client-ruby
182
190
  licenses: