fat_zebra 3.2.5 → 3.2.7

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.buildkite/pipeline.yml +34 -0
  3. data/.rubocop.yml +2 -2
  4. data/.tool-versions +1 -0
  5. data/.travis.yml +1 -4
  6. data/Gemfile +2 -0
  7. data/README.md +1 -1
  8. data/Rakefile +2 -0
  9. data/fat_zebra.gemspec +5 -1
  10. data/lib/fat_zebra/api_helper.rb +7 -4
  11. data/lib/fat_zebra/api_operation/delete.rb +2 -0
  12. data/lib/fat_zebra/api_operation/find.rb +2 -0
  13. data/lib/fat_zebra/api_operation/save.rb +2 -0
  14. data/lib/fat_zebra/api_operation/search.rb +2 -0
  15. data/lib/fat_zebra/api_operation/void.rb +2 -0
  16. data/lib/fat_zebra/api_resource.rb +11 -7
  17. data/lib/fat_zebra/authenticate.rb +2 -0
  18. data/lib/fat_zebra/bank_account.rb +2 -0
  19. data/lib/fat_zebra/batch.rb +5 -2
  20. data/lib/fat_zebra/card.rb +2 -0
  21. data/lib/fat_zebra/config.rb +3 -1
  22. data/lib/fat_zebra/customer.rb +2 -0
  23. data/lib/fat_zebra/direct_credit.rb +2 -0
  24. data/lib/fat_zebra/direct_debit.rb +2 -0
  25. data/lib/fat_zebra/errors.rb +3 -4
  26. data/lib/fat_zebra/fat_zebra_object.rb +2 -0
  27. data/lib/fat_zebra/information.rb +2 -0
  28. data/lib/fat_zebra/object_helper.rb +2 -0
  29. data/lib/fat_zebra/payment_plan.rb +2 -0
  30. data/lib/fat_zebra/paypal/authorization.rb +3 -1
  31. data/lib/fat_zebra/paypal/billing_agreement.rb +3 -1
  32. data/lib/fat_zebra/paypal/capture.rb +3 -1
  33. data/lib/fat_zebra/paypal/order.rb +3 -1
  34. data/lib/fat_zebra/paypal/refund.rb +3 -1
  35. data/lib/fat_zebra/purchase.rb +5 -2
  36. data/lib/fat_zebra/refund.rb +2 -0
  37. data/lib/fat_zebra/request/multipart/epilogue.rb +2 -0
  38. data/lib/fat_zebra/request/multipart/file_io.rb +2 -0
  39. data/lib/fat_zebra/request/multipart/param.rb +2 -0
  40. data/lib/fat_zebra/request/multipart/part.rb +3 -1
  41. data/lib/fat_zebra/request/multipart/stream.rb +3 -0
  42. data/lib/fat_zebra/request.rb +8 -5
  43. data/lib/fat_zebra/util.rb +4 -2
  44. data/lib/fat_zebra/utilities/apple_pay/domain.rb +48 -0
  45. data/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb +35 -0
  46. data/lib/fat_zebra/validation.rb +6 -4
  47. data/lib/fat_zebra/version.rb +4 -1
  48. data/lib/fat_zebra/web_hook.rb +2 -0
  49. data/lib/fat_zebra.rb +8 -0
  50. data/spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_delete_/deletes_the_domain.yml +52 -0
  51. data/spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_find_/fetches_the_domain.yml +86 -0
  52. data/spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_register_/creates_the_domain.yml +84 -0
  53. data/spec/lib/fat_zebra/utilities/apple_pay/domain_spec.rb +39 -0
  54. metadata +15 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 606ea77a4be37bc7df3d2556a643e485601bb92f20dbf8612a6b20b6fe59c8d5
4
- data.tar.gz: 0c1619ccf3607d9ea471db5ede1847e04f681e58dea61225caacc811cce98fad
3
+ metadata.gz: 491b920591c1b96455bdaf8267c96c0a1fa7ae4470dc9bd728e3ec2004159d62
4
+ data.tar.gz: 9cddd1413bb011093c8543c3c82bb72805384ce576d68ff5049b57bfcaf75889
5
5
  SHA512:
6
- metadata.gz: a56d0f166c623875bc0781e9e958511e938bb1ac8076624644e5a21012a0349a9ce4d8b6c4e5cb4aa7381949fe194825c547089471b7e89a99a4dafadd373b9e
7
- data.tar.gz: 4b44b153c380d149683b64c713b28a32caa49c064383efcfaf4d01c8319bdf2b30ad97872054d7b6e65f29421088311fddb57cd6d527120384f9a15c85ee27ee
6
+ metadata.gz: 0a0b351e5dbfa940924e50f24dd38342e3583f97296c4714ae59ed26e4e252f6628735fec7b8fd2ea06fb7c85f26f9b1dda937b6749eecac81c773f269378b39
7
+ data.tar.gz: 4e41b448bb9987d2633ab1b50e57d0fdfd8be24614be8b300a655bd025fed0c4698272c8da0b81714e50e5d507308f5c26c62ab6ba84f87f2d244c9dec8f67c6
@@ -0,0 +1,34 @@
1
+ steps:
2
+ - label: ":rspec: Run rspec"
3
+ command:
4
+ - "bundle install"
5
+ - "bundle exec rspec"
6
+ plugins:
7
+ - docker#v3.3.0:
8
+ image: ruby:2.7
9
+
10
+ - label: ":rubocop: Run the cop"
11
+ command:
12
+ - "bundle install"
13
+ - "echo 'running rubocop'"
14
+ - "bundle exec rubocop"
15
+ plugins:
16
+ - docker#v3.3.0:
17
+ image: ruby:2.7
18
+ - wait
19
+
20
+ - label: ":pick: Build and Push"
21
+ command:
22
+ - "bundle install"
23
+ - "gem build && gem push *.gem"
24
+ branches: master
25
+ plugins:
26
+ - docker#v3.3.0:
27
+ image: ruby:2.7
28
+ environment:
29
+ - GEM_HOST_API_KEY
30
+ - GIT_AUTHOR_NAME=Fat Zebra
31
+ - GIT_AUTHOR_EMAIL=support@fatzebra.com
32
+ agents:
33
+ queue: aws
34
+ Environment: test
data/.rubocop.yml CHANGED
@@ -7,7 +7,7 @@ Layout/EmptyLinesAroundBlockBody:
7
7
 
8
8
  Style/MissingRespondToMissing:
9
9
  Enabled: false
10
- Style/MethodMissingSuper:
10
+ Lint/MissingSuper:
11
11
  Enabled: false
12
12
  Style/NumericPredicate:
13
13
  Enabled: false
@@ -34,7 +34,7 @@ Documentation:
34
34
  Enabled: false
35
35
 
36
36
  AllCops:
37
- TargetRubyVersion: 2.2
37
+ TargetRubyVersion: 2.7
38
38
  Exclude:
39
39
  - bin/**/*
40
40
  - vendor/**/*
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.2.2
data/.travis.yml CHANGED
@@ -1,11 +1,8 @@
1
1
  cache: bundler
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3
5
- - 2.4
6
- - 2.5
7
- - 2.6
8
4
  - 2.7
5
+ - 3.2
9
6
  script:
10
7
  - bundle exec rspec spec
11
8
  - bundle exec rubocop
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in FatZebra.gemspec
data/README.md CHANGED
@@ -3,7 +3,7 @@ Ruby API Library for Fat Zebra
3
3
 
4
4
  [![Build Status](https://travis-ci.org/fatzebra/Ruby-Library.svg?branch=master)](https://travis-ci.org/fatzebra/Ruby-Library)
5
5
 
6
- Release 3.2.3 for API version 1.0
6
+ Release 3.2.6 for API version 1.0
7
7
 
8
8
  A Ruby client for the [Fat Zebra](https://www.fatzebra.com) Online Payment Gateway
9
9
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  require 'rspec/core/rake_task'
data/fat_zebra.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
 
@@ -16,10 +18,12 @@ Gem::Specification.new do |s|
16
18
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
17
19
  s.require_paths = %w[lib]
18
20
 
21
+ s.required_ruby_version = '>= 2.7'
22
+
19
23
  s.add_development_dependency 'byebug'
20
24
  s.add_development_dependency 'rake'
21
25
  s.add_development_dependency 'rspec', '~> 3.6'
22
- s.add_development_dependency 'rubocop', '~> 0.58.1'
26
+ s.add_development_dependency 'rubocop'
23
27
  s.add_development_dependency 'vcr', '~> 3.0'
24
28
  s.add_development_dependency 'webmock', '~> 3.0'
25
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Helper
@@ -40,20 +42,21 @@ module FatZebra
40
42
  port = port.to_i if port
41
43
 
42
44
  url_params = Util.compact(
43
- host: host,
44
- path: path,
45
- port: port,
45
+ host: host,
46
+ path: path,
47
+ port: port,
46
48
  query: params
47
49
  )
48
50
 
49
51
  return URI::HTTPS.build(url_params) if options[:http_secure]
52
+
50
53
  URI::HTTP.build(url_params)
51
54
  end
52
55
 
53
56
  def default_headers
54
57
  {
55
58
  headers: {
56
- accept: 'application/json',
59
+ accept: 'application/json',
57
60
  content_type: 'application/json'
58
61
  }
59
62
  }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  class APIOperation
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  class APIOperation
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  class APIOperation
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  class APIOperation
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  class APIOperation
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \API \Resource
@@ -30,16 +32,17 @@ module FatZebra
30
32
  uri = build_endpoint_url(configurations.gateway, path, url_params, http_secure: configurations.http_secure)
31
33
 
32
34
  request_options = Util.compact(
33
- method: method,
34
- url: uri.to_s,
35
+ method: method,
36
+ url: uri.to_s,
35
37
  payload: payload,
36
- proxy: configurations.proxy,
38
+ proxy: configurations.proxy,
37
39
  use_ssl: configurations.http_secure
38
40
  ).merge(authentication).merge(default_headers).merge(configurations.global_options).merge(options)
39
41
 
40
42
  Request.execute(request_options).body
41
- rescue FatZebra::RequestError => error
42
- return error.http_body if error.http_status == 422
43
+ rescue FatZebra::RequestError => e
44
+ return e.http_body if e.http_status == 422
45
+
43
46
  raise
44
47
  end
45
48
  # rubocop:enable Metrics/AbcSize
@@ -48,8 +51,9 @@ module FatZebra
48
51
 
49
52
  def ssl_options
50
53
  return {} unless configurations.http_secure
54
+
51
55
  {
52
- ca_file: File.expand_path(File.dirname(__FILE__) + '/../../vendor/cacert.pem'),
56
+ ca_file: File.expand_path("#{File.dirname(__FILE__)}/../../vendor/cacert.pem"),
53
57
  verify_mode: OpenSSL::SSL::VERIFY_PEER
54
58
  }
55
59
  end
@@ -57,7 +61,7 @@ module FatZebra
57
61
  def authentication
58
62
  {
59
63
  basic_auth: {
60
- user: configurations.username,
64
+ user: configurations.username,
61
65
  password: configurations.token
62
66
  }
63
67
  }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Authenticate
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Bank \Account
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Batch
@@ -51,8 +53,9 @@ module FatZebra
51
53
  # @return [String] formated as CSV
52
54
  def result(params = {}, options = {})
53
55
  request(:get, "#{resource_path}/#{id}/result.csv", params, options)
54
- rescue FatZebra::RequestError => error
55
- return error.http_body if error.http_status == 422
56
+ rescue FatZebra::RequestError => e
57
+ return e.http_body if e.http_status == 422
58
+
56
59
  raise
57
60
  end
58
61
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Card
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Config
@@ -7,7 +9,7 @@ module FatZebra
7
9
 
8
10
  GATEWAY_URLS = {
9
11
  production: 'gateway.fatzebra.com.au',
10
- sandbox: 'gateway.sandbox.fatzebra.com.au'
12
+ sandbox: 'gateway.sandbox.fatzebra.com.au'
11
13
  }.freeze
12
14
 
13
15
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Customer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Direct \Credit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Direct \Debit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
 
3
5
  ##
@@ -16,10 +18,7 @@ module FatZebra
16
18
  # Request to API Error
17
19
  class RequestError < StandardError
18
20
 
19
- attr_reader :http_body
20
- attr_reader :http_status
21
- attr_reader :http_status_type
22
- attr_reader :http_message
21
+ attr_reader :http_body, :http_status, :http_status_type, :http_message
23
22
 
24
23
  def initialize(response, message: nil)
25
24
  @http_status = response.code.to_i
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Information
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == Object \Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Payment \Plan
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Paypal::Authorization
@@ -16,7 +18,7 @@ module FatZebra
16
18
 
17
19
  class << self
18
20
  def base_path
19
- super + '/paypal/'
21
+ "#{super}/paypal/"
20
22
  end
21
23
 
22
24
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Paypal::BillingAgreement
@@ -21,7 +23,7 @@ module FatZebra
21
23
 
22
24
  class << self
23
25
  def base_path
24
- super + '/paypal/'
26
+ "#{super}/paypal/"
25
27
  end
26
28
 
27
29
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Paypal::Capture
@@ -15,7 +17,7 @@ module FatZebra
15
17
 
16
18
  class << self
17
19
  def base_path
18
- super + '/paypal/'
20
+ "#{super}/paypal/"
19
21
  end
20
22
 
21
23
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Paypal::Order
@@ -14,7 +16,7 @@ module FatZebra
14
16
 
15
17
  class << self
16
18
  def base_path
17
- super + '/paypal/'
19
+ "#{super}/paypal/"
18
20
  end
19
21
  end
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Paypal::Refund
@@ -14,7 +16,7 @@ module FatZebra
14
16
 
15
17
  class << self
16
18
  def base_path
17
- super + '/paypal/'
19
+ "#{super}/paypal/"
18
20
  end
19
21
  end
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Purchase
@@ -71,8 +73,8 @@ module FatZebra
71
73
  def refund(params = {}, options = {})
72
74
  Refund.create({
73
75
  transaction_id: id,
74
- amount: amount,
75
- reference: reference
76
+ amount: amount,
77
+ reference: reference
76
78
  }.merge(params), options)
77
79
  end
78
80
 
@@ -112,6 +114,7 @@ module FatZebra
112
114
  # @return [Response] Purchase response object
113
115
  def increment!(additional_amount, options = {})
114
116
  raise ArgumentError, 'Amount must be a positive amount' unless additional_amount > 0
117
+
115
118
  response = request(:put, resource_path("purchases/#{id}"), { amount: amount + additional_amount }, options)
116
119
  update_from(response)
117
120
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Refund
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Request \Multipart \Epilogue
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Request \Multipart \FileIO
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Request \Multipart \Param
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Request \Multipart \Part
@@ -7,7 +9,7 @@ module FatZebra
7
9
  module Multipart
8
10
  module Part
9
11
 
10
- LINE_BREAK = "\r\n".freeze
12
+ LINE_BREAK = "\r\n"
11
13
 
12
14
  def boundary
13
15
  '----FatZebraMultipartPost'
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Style/FrozenStringLiteralComment
1
2
  module FatZebra
2
3
  ##
3
4
  # == FatZebra \Request \Multipart \Stream
@@ -55,3 +56,5 @@ module FatZebra
55
56
  end
56
57
  end
57
58
  end
59
+
60
+ # rubocop:enable Style/FrozenStringLiteralComment
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fat_zebra/request/multipart/part'
2
4
  require 'fat_zebra/request/multipart/stream'
3
5
  require 'fat_zebra/request/multipart/epilogue'
@@ -15,13 +17,14 @@ module FatZebra
15
17
  def execute(params = {})
16
18
  klass = new(params)
17
19
 
18
- if params[:method] == :post
20
+ case params[:method]
21
+ when :post
19
22
  klass.post
20
- elsif params[:method] == :put
23
+ when :put
21
24
  klass.put
22
- elsif params[:method] == :delete
25
+ when :delete
23
26
  klass.delete
24
- elsif params[:method] == :get
27
+ when :get
25
28
  klass.get
26
29
  else
27
30
  raise FatZebra::UnknownRequestMethod, "#{params[:method]} haven't been implemented"
@@ -131,7 +134,7 @@ module FatZebra
131
134
  parts << Multipart::Epilogue.new
132
135
 
133
136
  request.content_length = parts.inject(0) { |sum, part| sum + part.length }
134
- request.content_type = 'multipart/form-data; boundary=' + parts.first.boundary
137
+ request.content_type = "multipart/form-data; boundary=#{parts.first.boundary}"
135
138
  request.body_stream = Multipart::Stream.new(parts.map(&:to_io))
136
139
  end
137
140
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  module Util
3
5
  class << self
4
6
 
5
- DATE_FORMAT = '%Y/%m/%d'.freeze
6
- REGEXP_HTTP = %r{http[s]?\:\/\/}
7
+ DATE_FORMAT = '%Y/%m/%d'
8
+ REGEXP_HTTP = %r{https?://}.freeze
7
9
 
8
10
  def cleanup_host(uri)
9
11
  uri.to_s.gsub(REGEXP_HTTP, '')
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FatZebra
4
+ module Utilities
5
+ module ApplePay
6
+ class Domain < APIResource
7
+
8
+ ENDPOINT_URL = '/v1.0/utilities/apple_pay/domains'
9
+
10
+ class << self
11
+
12
+ ##
13
+ # Register an Apple Pay (web) domain
14
+ #
15
+ # @return [FatZebra::Utilities::ApplePay::Domains] response
16
+ def register!(domain, params = {})
17
+ response = request(:post, path(domain), params)
18
+ initialize_from(response)
19
+ end
20
+
21
+ ##
22
+ # Check registration status of an Apple Pay (web) domain
23
+ #
24
+ # @return [FatZebra::Utilities::ApplePay::Domains] response
25
+ def find!(domain)
26
+ response = request(:get, path(domain))
27
+ initialize_from(response)
28
+ end
29
+
30
+ ##
31
+ # Delete an Apple Pay (web) domain
32
+ #
33
+ # @return [FatZebra::Utilities::ApplePay::Domains] response
34
+ def delete!(domain)
35
+ response = request(:delete, path(domain))
36
+ initialize_from(response)
37
+ end
38
+
39
+ private
40
+
41
+ def path(domain)
42
+ "#{ENDPOINT_URL}/#{domain}"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FatZebra
4
+ module Utilities
5
+ module Mastercard
6
+ module ClickToPay
7
+ class Registration < APIResource
8
+
9
+ ENDPOINT_URL = '/v1.0/utilities/mastercard/click_to_pay/registration'
10
+
11
+ class << self
12
+
13
+ ##
14
+ # Register with Mastercard Click To Pay
15
+ #
16
+ # @return [FatZebra::Utilities::Mastercard::ClickToPay::Registration] response
17
+ def register!
18
+ response = request(:post, ENDPOINT_URL)
19
+ initialize_from(response)
20
+ end
21
+
22
+ ##
23
+ # Lookup regisrtation with Mastercard Click To Pay
24
+ #
25
+ # @return [FatZebra::Utilities::Mastercard::ClickToPay::Registration] response
26
+ def registered?
27
+ response = request(:get, ENDPOINT_URL)
28
+ initialize_from(response)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  module Validation
3
5
 
@@ -39,7 +41,7 @@ module FatZebra
39
41
  errors << "'#{field}' is required" if params[field].nil? || params[field] == ''
40
42
  end
41
43
 
42
- # rubocop:disable Metrics/CyclomaticComplexity
44
+ # rubocop:disable Metrics/CyclomaticComplexity, Lint/MixedRegexpCaptureTypes
43
45
  def validate_type(field, options, params)
44
46
  regexp =
45
47
  case options
@@ -50,9 +52,9 @@ module FatZebra
50
52
  when :positive_integer
51
53
  /\A\d*\z/
52
54
  when :batch_filename
53
- /\ABATCH-(?<version>v\d)-(?<type>[A-Z]*)-((?<merchant_username>[A-Z0-9]*\-?[A-Z0-9]*)-)?(?<process_date>\d{8})-(?<reference>[a-zA-Z0-9\-_]*).csv\z/i
55
+ /\ABATCH-(?<version>v\d)-(?<type>[A-Z]*)-((?<merchant_username>[A-Z0-9]*-?[A-Z0-9]*)-)?(?<process_date>\d{8})-(?<reference>[a-zA-Z0-9\-_]*).csv\z/i
54
56
  when :file_type
55
- /\A\#\<File\:.*\z/
57
+ /\A\#<File:.*\z/
56
58
  when :boolean
57
59
  /\Atrue|false\z/
58
60
  else
@@ -61,7 +63,7 @@ module FatZebra
61
63
 
62
64
  errors << "'#{field}' is not a '#{options}'" unless params[field].to_s =~ regexp
63
65
  end
64
- # rubocop:enable Metrics/CyclomaticComplexity
66
+ # rubocop:enable Metrics/CyclomaticComplexity, Lint/MixedRegexpCaptureTypes
65
67
 
66
68
  end
67
69
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
- VERSION = '3.2.5'.freeze
4
+ VERSION = '3.2.7'
5
+
3
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FatZebra
2
4
  ##
3
5
  # == FatZebra \Web \Hook
data/lib/fat_zebra.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(__dir__) unless $LOAD_PATH.include?(__dir__)
4
+
1
5
  # Libraries
2
6
  require 'securerandom'
3
7
  require 'json'
@@ -38,6 +42,10 @@ require 'fat_zebra/bank_account'
38
42
  require 'fat_zebra/web_hook'
39
43
  require 'fat_zebra/batch'
40
44
 
45
+ # Utilities
46
+ require 'fat_zebra/utilities/apple_pay/domain'
47
+ require 'fat_zebra/utilities/mastercard/click_to_pay/registration'
48
+
41
49
  # Paypal API Resources
42
50
  require 'fat_zebra/paypal/billing_agreement'
43
51
  require 'fat_zebra/paypal/order'
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/utilities/apple_pay/domains/www.example99.com
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ response:
19
+ status:
20
+ code: 202
21
+ message: Accepted
22
+ headers:
23
+ Date:
24
+ - Mon, 04 Mar 2024 01:10:33 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Status:
32
+ - 202 Accepted
33
+ Cache-Control:
34
+ - no-store
35
+ Vary:
36
+ - Accept
37
+ Pragma:
38
+ - no-cache
39
+ X-Request-Id:
40
+ - 3f319fea5d6aa95004cab8f5
41
+ X-Runtime:
42
+ - '0.033681'
43
+ X-Backend:
44
+ - gateway
45
+ Strict-Transport-Security:
46
+ - max-age=31536000; includeSubDomains
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"successful":true,"response":{},"errors":[],"test":true}'
50
+ http_version:
51
+ recorded_at: Mon, 04 Mar 2024 01:10:33 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,86 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/utilities/apple_pay/domains/www.example.com?test=true
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - gateway.sandbox.fatzebra.com.au
18
+ Authorization:
19
+ - Basic VEVTVDpURVNU
20
+ Content-Type:
21
+ - application/json
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Date:
28
+ - Mon, 04 Mar 2024 01:10:33 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 200 OK
37
+ Cache-Control:
38
+ - no-store
39
+ Vary:
40
+ - Accept
41
+ Pragma:
42
+ - no-cache
43
+ X-Request-Id:
44
+ - 5347a0df5e2ebe022d005a3a
45
+ X-Runtime:
46
+ - '0.030516'
47
+ X-Backend:
48
+ - gateway
49
+ Strict-Transport-Security:
50
+ - max-age=31536000; includeSubDomains
51
+ Content-Security-Policy-Report-Only:
52
+ - 'child-src ''self'' blob: *.cardinalcommerce.com fatzebra.statuspage.io; connect-src
53
+ ''self'' *.mastercard.com *.forter.com *.pmnts-staging.io *.rollbar.com *.nr-data.net
54
+ *.cardinalcommerce.com fatzebra.statuspage.io *.googleapis.com *.google-analytics.com;
55
+ default-src ''self'' ''unsafe-eval'' ''unsafe-inline'' *.forter.com *.nr-data.net
56
+ blob: *.pmnts-sandbox.io *.rollbar.com fatzebra.statuspage.io *.iovation.com
57
+ data: *.googleapis.com *.gstatic.com *.newrelic.com *.bootstrapcdn.com www.google.com
58
+ pay.google.com *.google-analytics.com *.gravatar.com; font-src ''self'' cdnjs.cloudflare.com
59
+ data: *.gstatic.com *.bootstrapcdn.com *.aexp-static.com; form-action ''self''
60
+ *.cardinalcommerce.com; frame-ancestors ''self''; frame-src ''self'' fatzebra.statuspage.io
61
+ *.americanexpress.com www.google.com pay.google.com *.masterpass.com *.visa.com
62
+ *.mastercard.com; img-src ''self'' *.visa.com data: *.googleapis.com *.gstatic.com
63
+ masterpass.com *.masterpass.com *.americanexpress.com *.google-analytics.com
64
+ *.gravatar.com; script-src ''self'' ''unsafe-eval'' ''unsafe-inline'' *.forter.com
65
+ *.nr-data.net *.pmnts-sandbox.io *.pmnts-staging.io *.rollbar.com fatzebra.statuspage.io
66
+ cdnjs.cloudflare.com *.iovation.com *.jquery.com *.newrelic.com *.googleapis.com
67
+ *.cardinalcommerce.com *.bootstrapcdn.com wasm-eval *.google-analytics.com
68
+ *.googletagmanager.com; script-src-attr ''unsafe-inline''; script-src-elem
69
+ ''self'' ''unsafe-inline'' *.forter.com *.nr-data.net *.pmnts-sandbox.io *.rollbar.com
70
+ fatzebra.statuspage.io *.iovation.com *.jquery.com cdnjs.cloudflare.com *.pmnts-staging.io
71
+ *.aexp-static.com *.newrelic.com *.googleapis.com *.americanexpress.com www.google.com
72
+ pay.google.com *.visa.com *.masterpass.com *.mastercard.com *.google-analytics.com
73
+ *.gstatic.com *.bootstrapcdn.com; style-src ''self'' ''unsafe-eval'' ''unsafe-inline''
74
+ *.bootstrapcdn.com *.googleapis.com; style-src-attr ''unsafe-inline''; style-src-elem
75
+ ''unsafe-inline'' ''self'' *.googleapis.com cdnjs.cloudflare.com *.bootstrapcdn.com;
76
+ worker-src blob:; report-uri https://fatzebra.report-uri.com/r/d/csp/wizard'
77
+ Nel:
78
+ - '{"report_to":"default","max_age":31536000,"include_subdomains":true}'
79
+ Report-To:
80
+ - '{"group":"default","max_age":31536000,"endpoints":[{"url":"https://fatzebra.report-uri.com/a/d/g"}],"include_subdomains":true}'
81
+ body:
82
+ encoding: UTF-8
83
+ string: '{"successful":true,"response":{"status":"Active","domain":"www.example.com","created_at":"2023-04-14T15:15:45+10:00","updated_at":"2023-04-14T05:15:47+00:00"},"errors":[],"test":true}'
84
+ http_version:
85
+ recorded_at: Mon, 04 Mar 2024 01:10:32 GMT
86
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,84 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/utilities/apple_pay/domains/www.example99.com
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"async":false,"test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ Content-Type:
19
+ - application/json
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Mon, 04 Mar 2024 01:10:32 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Status:
34
+ - 200 OK
35
+ Cache-Control:
36
+ - no-store
37
+ Vary:
38
+ - Accept
39
+ Pragma:
40
+ - no-cache
41
+ X-Request-Id:
42
+ - 298c3b404da4ccb5139e44ce
43
+ X-Runtime:
44
+ - '3.097708'
45
+ X-Backend:
46
+ - gateway
47
+ Strict-Transport-Security:
48
+ - max-age=31536000; includeSubDomains
49
+ Content-Security-Policy-Report-Only:
50
+ - 'child-src ''self'' blob: *.cardinalcommerce.com fatzebra.statuspage.io; connect-src
51
+ ''self'' *.mastercard.com *.forter.com *.pmnts-staging.io *.rollbar.com *.nr-data.net
52
+ *.cardinalcommerce.com fatzebra.statuspage.io *.googleapis.com *.google-analytics.com;
53
+ default-src ''self'' ''unsafe-eval'' ''unsafe-inline'' *.forter.com *.nr-data.net
54
+ blob: *.pmnts-sandbox.io *.rollbar.com fatzebra.statuspage.io *.iovation.com
55
+ data: *.googleapis.com *.gstatic.com *.newrelic.com *.bootstrapcdn.com www.google.com
56
+ pay.google.com *.google-analytics.com *.gravatar.com; font-src ''self'' cdnjs.cloudflare.com
57
+ data: *.gstatic.com *.bootstrapcdn.com *.aexp-static.com; form-action ''self''
58
+ *.cardinalcommerce.com; frame-ancestors ''self''; frame-src ''self'' fatzebra.statuspage.io
59
+ *.americanexpress.com www.google.com pay.google.com *.masterpass.com *.visa.com
60
+ *.mastercard.com; img-src ''self'' *.visa.com data: *.googleapis.com *.gstatic.com
61
+ masterpass.com *.masterpass.com *.americanexpress.com *.google-analytics.com
62
+ *.gravatar.com; script-src ''self'' ''unsafe-eval'' ''unsafe-inline'' *.forter.com
63
+ *.nr-data.net *.pmnts-sandbox.io *.pmnts-staging.io *.rollbar.com fatzebra.statuspage.io
64
+ cdnjs.cloudflare.com *.iovation.com *.jquery.com *.newrelic.com *.googleapis.com
65
+ *.cardinalcommerce.com *.bootstrapcdn.com wasm-eval *.google-analytics.com
66
+ *.googletagmanager.com; script-src-attr ''unsafe-inline''; script-src-elem
67
+ ''self'' ''unsafe-inline'' *.forter.com *.nr-data.net *.pmnts-sandbox.io *.rollbar.com
68
+ fatzebra.statuspage.io *.iovation.com *.jquery.com cdnjs.cloudflare.com *.pmnts-staging.io
69
+ *.aexp-static.com *.newrelic.com *.googleapis.com *.americanexpress.com www.google.com
70
+ pay.google.com *.visa.com *.masterpass.com *.mastercard.com *.google-analytics.com
71
+ *.gstatic.com *.bootstrapcdn.com; style-src ''self'' ''unsafe-eval'' ''unsafe-inline''
72
+ *.bootstrapcdn.com *.googleapis.com; style-src-attr ''unsafe-inline''; style-src-elem
73
+ ''unsafe-inline'' ''self'' *.googleapis.com cdnjs.cloudflare.com *.bootstrapcdn.com;
74
+ worker-src blob:; report-uri https://fatzebra.report-uri.com/r/d/csp/wizard'
75
+ Nel:
76
+ - '{"report_to":"default","max_age":31536000,"include_subdomains":true}'
77
+ Report-To:
78
+ - '{"group":"default","max_age":31536000,"endpoints":[{"url":"https://fatzebra.report-uri.com/a/d/g"}],"include_subdomains":true}'
79
+ body:
80
+ encoding: UTF-8
81
+ string: '{"successful":true,"response":{"status":"Active","domain":"www.example99.com","created_at":"2024-03-04T12:10:29+11:00","updated_at":"2024-03-04T01:10:31+00:00"},"errors":[],"test":true}'
82
+ http_version:
83
+ recorded_at: Mon, 04 Mar 2024 01:10:32 GMT
84
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe FatZebra::Utilities::ApplePay::Domain do
4
+
5
+ describe '.register!', :vcr do
6
+ subject(:create) { FatZebra::Utilities::ApplePay::Domain.register!(domain, valid_payload) }
7
+
8
+ let!(:domain) { "www.example99.com" }
9
+ let!(:valid_payload) {{
10
+ async: false
11
+ }}
12
+
13
+ it "creates the domain" do
14
+ expect(create).to be_accepted
15
+ expect(create.domain).to eq(domain)
16
+ expect(create.status).to eq("Active")
17
+ end
18
+ end
19
+
20
+ describe '.find!', :vcr do
21
+ subject(:find) { FatZebra::Utilities::ApplePay::Domain.find!(domain) }
22
+ let!(:domain) { "www.example.com" }
23
+
24
+ it "fetches the domain" do
25
+ expect(find).to be_accepted
26
+ expect(find.domain).to eq(domain)
27
+ expect(find.status).to eq("Active")
28
+ end
29
+ end
30
+
31
+ describe '.delete!', :vcr do
32
+ subject(:delete) { FatZebra::Utilities::ApplePay::Domain.delete!(domain) }
33
+ let!(:domain) { "www.example99.com" }
34
+
35
+ it "deletes the domain" do
36
+ expect(delete).to be_accepted
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_zebra
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.5
4
+ version: 3.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fat Zebra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-11 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.58.1
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.58.1
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: vcr
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -102,9 +102,11 @@ executables: []
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".buildkite/pipeline.yml"
105
106
  - ".gitignore"
106
107
  - ".rspec"
107
108
  - ".rubocop.yml"
109
+ - ".tool-versions"
108
110
  - ".travis.yml"
109
111
  - Gemfile
110
112
  - README.md
@@ -145,6 +147,8 @@ files:
145
147
  - lib/fat_zebra/request/multipart/part.rb
146
148
  - lib/fat_zebra/request/multipart/stream.rb
147
149
  - lib/fat_zebra/util.rb
150
+ - lib/fat_zebra/utilities/apple_pay/domain.rb
151
+ - lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb
148
152
  - lib/fat_zebra/validation.rb
149
153
  - lib/fat_zebra/version.rb
150
154
  - lib/fat_zebra/web_hook.rb
@@ -327,6 +331,9 @@ files:
327
331
  - spec/cassettes/FatZebra_Refund/_void/1_4_2.yml
328
332
  - spec/cassettes/FatZebra_Refund/_void/1_4_3.yml
329
333
  - spec/cassettes/FatZebra_Refund/_void/1_4_4.yml
334
+ - spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_delete_/deletes_the_domain.yml
335
+ - spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_find_/fetches_the_domain.yml
336
+ - spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_register_/creates_the_domain.yml
330
337
  - spec/cassettes/FatZebra_WebHook/_create/1_1_1.yml
331
338
  - spec/cassettes/FatZebra_WebHook/_create/1_1_2.yml
332
339
  - spec/cassettes/FatZebra_WebHook/_create/1_1_3.yml
@@ -357,6 +364,7 @@ files:
357
364
  - spec/lib/fat_zebra/refund_spec.rb
358
365
  - spec/lib/fat_zebra/request_spec.rb
359
366
  - spec/lib/fat_zebra/util_spec.rb
367
+ - spec/lib/fat_zebra/utilities/apple_pay/domain_spec.rb
360
368
  - spec/lib/fat_zebra/validation_spec.rb
361
369
  - spec/lib/fat_zebra/web_hook_spec.rb
362
370
  - spec/spec_helper.rb
@@ -373,7 +381,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
373
381
  requirements:
374
382
  - - ">="
375
383
  - !ruby/object:Gem::Version
376
- version: '0'
384
+ version: '2.7'
377
385
  required_rubygems_version: !ruby/object:Gem::Requirement
378
386
  requirements:
379
387
  - - ">="