bambora-client 0.1.0 → 0.3.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
  SHA256:
3
- metadata.gz: 60f0ed5088f0e4f5b63e9335431dffc7562d2239d237a08ac45cbc116f118fce
4
- data.tar.gz: 59bd1a213dde32eb67be6802e5621cf527c64e9b50a835fe754ecb663588a8fd
3
+ metadata.gz: c558cd0eb1fa8548cbe1f789247e8212eef01751816352f16a5de1d481c8d976
4
+ data.tar.gz: 41c21bf3ff0c31642177d5f7cd170a9cf955903a8f451d4f4c6f0a8a281366b9
5
5
  SHA512:
6
- metadata.gz: 4bdbdf83b22c92b96bb6c04f71cfbfaaa2f5679e94cb2b00b431398cf09624f34e334201bcbe1e4efd2b4bd4bfb4a17c87058dfec438bff0c913075060a04411
7
- data.tar.gz: 194b507146db394ceee4d59848a2126422224752d68f391fd8f866db5a9d0fc5785e4b22b2de4b94d9710d7bf0a58e0687d8e69053bb7819d1be7254ea1ca853
6
+ metadata.gz: 53e587d5ae1e54ce4042d80f1e5a9869cad0a11d47a733322ceeca1f4a727fdbc86a70b9e029a358413d2044a7dc3209c6988230c25bc46f08ef62a60dcf6640
7
+ data.tar.gz: 467774ca8f4ea52e0fc23e91a41182d67a162bcc7554083c6824437800bb9f8f9909bfca9ec8752b224aebf75f2b8cad281f5cc0a20959f8e668524c7743d95a
@@ -0,0 +1,31 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v* # Only run when we carve a new tag
7
+
8
+ jobs:
9
+ build:
10
+ name: Build + Publish
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby 2.6
16
+ uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6.x
19
+
20
+ - name: Publish to RubyGems
21
+ run: |
22
+ mkdir -p $HOME/.gem
23
+ touch $HOME/.gem/credentials
24
+ chmod 0600 $HOME/.gem/credentials
25
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
26
+ gem build *.gemspec
27
+ gem push *.gem
28
+ env:
29
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
30
+
31
+
data/.gitignore CHANGED
@@ -9,3 +9,7 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ bambora-client-*.gem
13
+
14
+ # Ruby-specific files
15
+ Gemfile.lock
@@ -0,0 +1,24 @@
1
+ ## 0.3.0 (2020-05-27)
2
+
3
+ - Add `Bambora::V1::ProfileResource#update` method
4
+
5
+ ## 0.2.0 (2020-05-11)
6
+
7
+ - Add `Bambora::V1::ProfileResource#get` method
8
+
9
+ ## 0.1.3 (2020-04-30)
10
+
11
+ - Ensure Batch Report returns empty array `:record` in response at the very least
12
+
13
+ ## 0.1.2 (2020-04-14)
14
+
15
+ - Fix nil record with Bank Batch Report returns
16
+
17
+ ## 0.1.1 (2020-03-04)
18
+
19
+ - Upgrade `rake` to `13.0.1`
20
+ - Update README to notify Bambora dev support when functionality changes
21
+
22
+ ## 0.1.0 (2020-02-03)
23
+
24
+ - First major release
data/README.md CHANGED
@@ -92,6 +92,31 @@ profiles.delete(customer_code: '02355E2e58Bf488EAB4EaFAD7083dB6A')
92
92
  # }
93
93
  ```
94
94
 
95
+ ### Update a Profile
96
+
97
+ ```ruby
98
+ profiles.update(
99
+ customer_code: '02355E2e58Bf488EAB4EaFAD7083dB6A',
100
+ payment_profile_data: {
101
+ language: 'en',
102
+ comments: 'hello',
103
+ card: {
104
+ name: 'Hup Podling',
105
+ number: '4030000010001234',
106
+ expiry_month: '12',
107
+ expiry_year: '23',
108
+ cvd: '123',
109
+ },
110
+ },
111
+ )
112
+
113
+ # => {
114
+ # :code => 1,
115
+ # :message => "Operation Successful",
116
+ # :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
117
+ # }
118
+ ```
119
+
95
120
  ### Payments
96
121
 
97
122
  *Summary*: Process payments using Credit Card, Payment Profile, Legato Token, Cash, Cheque, Interac, Apple Pay, or
@@ -188,6 +213,10 @@ Bug reports and pull requests are welcome on GitHub at
188
213
  intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
189
214
  [Contributor Covenant](http://contributor-covenant.org) code of conduct.
190
215
 
216
+ Your contributions are important. For larger changes to the behaviour of this client, or when adding new pieces of
217
+ functionality, please inform Bambora. You can get in touch with their
218
+ [developer support](https://dev.na.bambora.com/docs/support/) for advice.
219
+
191
220
  ## License
192
221
 
193
222
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
19
  # to allow pushing to a single host or delete this section to allow pushing to any host.
20
20
  if spec.respond_to?(:metadata)
21
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
22
22
 
23
23
  spec.metadata['homepage_uri'] = spec.homepage
24
24
  spec.metadata['source_code_uri'] = 'https://github.com/HiMamaInc/bambora-client'
@@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency 'bundler', '~> 2'
48
48
  spec.add_development_dependency 'pry', '~> 0.12.0'
49
49
  spec.add_development_dependency 'pry-byebug', '~> 3.7'
50
- spec.add_development_dependency 'rake', '~> 10.0'
50
+ spec.add_development_dependency 'rake', '~> 13.0'
51
51
  spec.add_development_dependency 'rspec', '~> 3.0'
52
52
  spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
53
53
  spec.add_development_dependency 'rubocop', '~> 0.74.0'
@@ -53,17 +53,28 @@ module Bambora
53
53
  #
54
54
  # @params profile_data [Hash] with values as noted in the example.
55
55
  def show(report_data)
56
- add_messages_to_response(
57
- client.post(path: sub_path, body: batch_report_body(report_data)),
58
- )
56
+ response = client.post(path: sub_path, body: batch_report_body(report_data))
57
+
58
+ response = ensure_record_key_exists(response)
59
+ response = add_messages_to_response(response)
60
+
61
+ response
59
62
  end
60
63
 
61
64
  private
62
65
 
66
+ def ensure_record_key_exists(response)
67
+ # bambora can return null or empty record results, fill it in for consistency
68
+ response.dig(:response)[:record] = [] if response.dig(:response, :record).nil?
69
+
70
+ response
71
+ end
72
+
63
73
  def add_messages_to_response(response)
64
74
  response.dig(:response, :record).map! do |record|
65
75
  record.merge!(messages: record[:messageId].split(',').map { |id| MESSAGES[id] })
66
76
  end
77
+
67
78
  response
68
79
  end
69
80
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bambora
4
4
  class Client
5
- VERSION = '0.1.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -38,6 +38,10 @@ module Bambora
38
38
  end
39
39
  end
40
40
 
41
+ def put(path:, body:, headers:)
42
+ connection.put(path, body, headers)
43
+ end
44
+
41
45
  def connection
42
46
  @connection ||= Faraday.new(url: base_url) do |faraday|
43
47
  faraday.request :multipart
@@ -99,6 +99,55 @@ module Bambora
99
99
  ).to_h
100
100
  end
101
101
 
102
+ # Make a PUT Request.
103
+ #
104
+ # @example
105
+ #
106
+ # client = Bambora::Rest::JSONClient(base_url: '...', merchant_id: '...')
107
+ #
108
+ # data = {
109
+ # billing: {
110
+ # name: "joh doe",
111
+ # address_line1: "123 main st",
112
+ # address_line2: "111",
113
+ # city: "victoria",
114
+ # province: "bc",
115
+ # country: "ca",
116
+ # postal_code: "V8T4M3",
117
+ # phone_number: "25012312345",
118
+ # email_address: "bill@smith.com"
119
+ # },
120
+ # card: {
121
+ # name: 'Hup Podling',
122
+ # number: '4030000010001234',
123
+ # expiry_month: '12',
124
+ # expiry_year: '23',
125
+ # cvd: '123',
126
+ # },
127
+ # }
128
+ #
129
+ # client.put(
130
+ # path: 'v1/profiles',
131
+ # body: data,
132
+ # api_key: '...'
133
+ # )
134
+ # # => {
135
+ # # :code => 1,
136
+ # # :message => "Operation Successful",
137
+ # # :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
138
+ # # }
139
+ #
140
+ # @param path [String] Indicating request path.
141
+ # @param body [Hash] Data to be sent in the body of the request.
142
+ # @param api_key [String] Indicating the API Key to be used with the request.
143
+ #
144
+ # @return [Hash] Indicating success or failure of the operation.
145
+ def put(path:, body:, api_key:)
146
+ parse_response_body(
147
+ super(path: path, body: body.to_json.to_s, headers: build_headers(api_key: api_key)),
148
+ ).to_h
149
+ end
150
+
102
151
  private
103
152
 
104
153
  def build_headers(api_key:)
@@ -54,8 +54,94 @@ module Bambora
54
54
  # @see https://dev.na.bambora.com/docs/guides/payment_profiles
55
55
  #
56
56
  # @return [Hash] Indicating success or failure of the operation.
57
- def create(card_data)
58
- client.post(path: sub_path, body: card_data, api_key: api_key)
57
+ def create(payment_profile_data)
58
+ client.post(path: sub_path, body: payment_profile_data, api_key: api_key)
59
+ end
60
+
61
+ ##
62
+ # Get a Bambora payment profile given a customer code.
63
+ #
64
+ # @example
65
+ #
66
+ # client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
67
+ # profiles = Bambora::V1::ProfileResource(client: client)
68
+ # customer_code = '02355E2e58Bf488EAB4EaFAD7083dB6A'
69
+ #
70
+ # profiles.get(customer_code: customer_code)
71
+ # # => {
72
+ # # :code => 1,
73
+ # # :message => "Operation Successful",
74
+ # # :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
75
+ # # :status => "A",
76
+ # # :last_transaction => "1900-01-01T00:00:00",
77
+ # # :modified_date => "1900-01-01T00:00:00",
78
+ # # :card => { :name => "", :number => "", :card_type => "" },
79
+ # # :language => "en",
80
+ # # :velocity_group => "",
81
+ # # :profile_group => "",
82
+ # # :account_ref => "",
83
+ # # :billing =>
84
+ # # {
85
+ # # :name => "Harry Lewis",
86
+ # # :address_line1 => "",
87
+ # # :address_line2 => "",
88
+ # # :city => "",
89
+ # # :province => "",
90
+ # # :country => "",
91
+ # # :postal_code => "",
92
+ # # :phone_number => "",
93
+ # # :email_address => ""},
94
+ # # :custom => { :ref1 => "", :ref2 => "", :ref3 => "", :ref4 => "", :ref5 => "" }}
95
+ #
96
+ # @param customer_code [String] A unique identifier for the associated payment profile.
97
+ #
98
+ # @return [Hash] Payment profile details.
99
+ def get(customer_code:)
100
+ client.get(path: "#{sub_path}/#{customer_code}", api_key: api_key)
101
+ end
102
+
103
+ # Make a PUT Request.
104
+ #
105
+ # @example
106
+ #
107
+ # client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
108
+ # profiles = Bambora::V1::ProfileResource(client: client)
109
+ # customer_code = '02355E2e58Bf488EAB4EaFAD7083dB6A'
110
+ #
111
+ # data = {
112
+ # billing: {
113
+ # name: "joh doe",
114
+ # address_line1: "123 main st",
115
+ # address_line2: "111",
116
+ # city: "victoria",
117
+ # province: "bc",
118
+ # country: "ca",
119
+ # postal_code: "V8T4M3",
120
+ # phone_number: "25012312345",
121
+ # email_address: "bill@smith.com"
122
+ # },
123
+ # card: {
124
+ # name: 'Hup Podling',
125
+ # number: '4030000010001234',
126
+ # expiry_month: '12',
127
+ # expiry_year: '23',
128
+ # cvd: '123',
129
+ # },
130
+ # }
131
+ #
132
+ # profiles.update(customer_code: customer_code, payment_profile_data: data)
133
+ # # => {
134
+ # # :code => 1,
135
+ # # :message => "Operation Successful",
136
+ # # :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
137
+ # # }
138
+ #
139
+ # @param customer_code [String] A unique identifier for the associated payment profile.
140
+ # @param data [Hash] Payment profile data to be sent in the body of the request.
141
+ #
142
+ # @return [Hash] Indicating success or failure of the operation.
143
+ def update(customer_code:, payment_profile_data:)
144
+ client.put(path: "#{@sub_path}/#{customer_code}", body: payment_profile_data, api_key: api_key)
59
145
  end
60
146
 
61
147
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bambora-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cassidy K
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '10.0'
117
+ version: '13.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '10.0'
124
+ version: '13.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -187,15 +187,16 @@ executables: []
187
187
  extensions: []
188
188
  extra_rdoc_files: []
189
189
  files:
190
+ - ".github/workflows/gempush.yml"
190
191
  - ".github/workflows/linter.yml"
191
192
  - ".github/workflows/ruby.yml"
192
193
  - ".gitignore"
193
194
  - ".rspec"
194
195
  - ".rubocop.yml"
195
196
  - ".ruby-version"
197
+ - CHANGELOG.md
196
198
  - CODE_OF_CONDUCT.md
197
199
  - Gemfile
198
- - Gemfile.lock
199
200
  - LICENSE.txt
200
201
  - README.md
201
202
  - Rakefile
@@ -249,7 +250,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
250
  - !ruby/object:Gem::Version
250
251
  version: '0'
251
252
  requirements: []
252
- rubygems_version: 3.1.2
253
+ rubyforge_project:
254
+ rubygems_version: 2.7.6.2
253
255
  signing_key:
254
256
  specification_version: 4
255
257
  summary: A thread-safe client for the Bambora/Beanstream API.
@@ -1,93 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- bambora-client (0.1.0)
5
- excon (< 1.0)
6
- faraday (< 1.0)
7
- gyoku (~> 1.0)
8
- multiparty (~> 0)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- addressable (2.7.0)
14
- public_suffix (>= 2.0.2, < 5.0)
15
- ast (2.4.0)
16
- builder (3.2.4)
17
- byebug (11.0.1)
18
- coderay (1.1.2)
19
- crack (0.4.3)
20
- safe_yaml (~> 1.0.0)
21
- diff-lcs (1.3)
22
- excon (0.71.0)
23
- faraday (0.17.1)
24
- multipart-post (>= 1.2, < 3)
25
- gyoku (1.3.1)
26
- builder (>= 2.1.2)
27
- hashdiff (1.0.0)
28
- jaro_winkler (1.5.3)
29
- method_source (0.9.2)
30
- mime-types (3.3)
31
- mime-types-data (~> 3.2015)
32
- mime-types-data (3.2019.1009)
33
- multipart-post (2.1.1)
34
- multiparty (0.2.0)
35
- mime-types
36
- parallel (1.18.0)
37
- parser (2.6.5.0)
38
- ast (~> 2.4.0)
39
- pry (0.12.2)
40
- coderay (~> 1.1.0)
41
- method_source (~> 0.9.0)
42
- pry-byebug (3.7.0)
43
- byebug (~> 11.0)
44
- pry (~> 0.10)
45
- public_suffix (4.0.1)
46
- rainbow (3.0.0)
47
- rake (10.5.0)
48
- rspec (3.9.0)
49
- rspec-core (~> 3.9.0)
50
- rspec-expectations (~> 3.9.0)
51
- rspec-mocks (~> 3.9.0)
52
- rspec-core (3.9.0)
53
- rspec-support (~> 3.9.0)
54
- rspec-expectations (3.9.0)
55
- diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.9.0)
57
- rspec-mocks (3.9.0)
58
- diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.9.0)
60
- rspec-support (3.9.0)
61
- rspec_junit_formatter (0.4.1)
62
- rspec-core (>= 2, < 4, != 2.12.0)
63
- rubocop (0.74.0)
64
- jaro_winkler (~> 1.5.1)
65
- parallel (~> 1.10)
66
- parser (>= 2.6)
67
- rainbow (>= 2.2.2, < 4.0)
68
- ruby-progressbar (~> 1.7)
69
- unicode-display_width (>= 1.4.0, < 1.7)
70
- ruby-progressbar (1.10.1)
71
- safe_yaml (1.0.5)
72
- unicode-display_width (1.6.0)
73
- webmock (3.7.6)
74
- addressable (>= 2.3.6)
75
- crack (>= 0.3.2)
76
- hashdiff (>= 0.4.0, < 2.0.0)
77
-
78
- PLATFORMS
79
- ruby
80
-
81
- DEPENDENCIES
82
- bambora-client!
83
- bundler (~> 2)
84
- pry (~> 0.12.0)
85
- pry-byebug (~> 3.7)
86
- rake (~> 10.0)
87
- rspec (~> 3.0)
88
- rspec_junit_formatter (~> 0.4.1)
89
- rubocop (~> 0.74.0)
90
- webmock (~> 3.7)
91
-
92
- BUNDLED WITH
93
- 2.1.0