gocardless_pro 2.40.0 → 2.41.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
  SHA256:
3
- metadata.gz: e651254dd1b8ee279f19b5c698c1cc0d71412186c7ffc472cd92d403c694d41f
4
- data.tar.gz: 493fc00fae5258c12b24d6a13fff0d2c76db9948b3898a782a6cf4eb59b281c8
3
+ metadata.gz: 54e49d4ec8bdde6078ef0bef2d7b64552070a6114fc7eb5073ad9df5b8346ad7
4
+ data.tar.gz: 4e7b1b362161c3f84fba2d2de48a08cf9d3168417c5f96c630c13f8cb9418a06
5
5
  SHA512:
6
- metadata.gz: 907c66f3f805bca23f58fea3c35893b1dd7623e6003d293f04fc8afeb667268a28f0dae259bed2255b97acd8c970cacaebedfc6e8b8d49365a23def27f544aa4
7
- data.tar.gz: 5f242c38777b4b9747fdca04e4dc335a9ffb740cc82b2af16dd21558a603786bc7cb5f80ad355423522ca2300a0bfc7664b41af20e0630bdff298d3d730ae821
6
+ metadata.gz: 785d50c105361f93a7a0be17ce38f09fc19ebc5b3738eeba6b0aa82212336c61e113b875e1b575c60534c9cdff764f1ce0710a131eeaa1a767d0667a757ca1d6
7
+ data.tar.gz: 0d0e24924d3e6f1dcfc9353b53ed5124600be89a62744899389c0afb99598d93b9678b85b0054c49174a94097c5cae6a0e59e1cd56ab17e355622ee028fce40f
@@ -1,8 +1,6 @@
1
1
  name: gocardless/gocardless-pro-ruby/tests
2
- on:
3
- push:
4
- branches:
5
- - master
2
+ on: push
3
+
6
4
  env:
7
5
  RUBYGEM_PUBLISH_API_KEY: ${{ secrets.RUBYGEM_PUBLISH_API_KEY }}
8
6
  jobs:
@@ -25,7 +23,7 @@ jobs:
25
23
  - uses: actions/checkout@v2
26
24
  - run: bundle install && bundle exec rspec
27
25
  publish:
28
- if: contains('refs/heads/master', github.ref)
26
+ if: github.ref == 'refs/heads/master'
29
27
  runs-on: ubuntu-latest
30
28
  container:
31
29
  image: ruby:2.6
data/Gemfile CHANGED
@@ -3,7 +3,8 @@ gemspec
3
3
 
4
4
  # We support both pre-1.x and post-1.x Faraday versions, but to ensure compatibility we
5
5
  # pin this gem against each in separate runs of CI, using the FARADAY_VERSION env var. For
6
- # more details on the values, see .circleci/config.yml.
6
+ # more details on the values, see .github/workflows/tests.yml in the gocardless-pro-ruby
7
+ # repository.
7
8
  if ENV.key?("FARADAY_VERSION")
8
9
  gem 'faraday', "~> #{ENV["FARADAY_VERSION"]}"
9
10
  end
@@ -133,6 +133,11 @@ module GoCardlessPro
133
133
  @scenario_simulators ||= Services::ScenarioSimulatorsService.new(@api_service)
134
134
  end
135
135
 
136
+ # Access to the service for scheme_identifier to make API calls
137
+ def scheme_identifiers
138
+ @scheme_identifiers ||= Services::SchemeIdentifiersService.new(@api_service)
139
+ end
140
+
136
141
  # Access to the service for subscription to make API calls
137
142
  def subscriptions
138
143
  @subscriptions ||= Services::SubscriptionsService.new(@api_service)
@@ -143,6 +148,11 @@ module GoCardlessPro
143
148
  @tax_rates ||= Services::TaxRatesService.new(@api_service)
144
149
  end
145
150
 
151
+ # Access to the service for verification_detail to make API calls
152
+ def verification_details
153
+ @verification_details ||= Services::VerificationDetailsService.new(@api_service)
154
+ end
155
+
146
156
  # Access to the service for webhook to make API calls
147
157
  def webhooks
148
158
  @webhooks ||= Services::WebhooksService.new(@api_service)
@@ -198,7 +208,7 @@ module GoCardlessPro
198
208
  'User-Agent' => user_agent.to_s,
199
209
  'Content-Type' => 'application/json',
200
210
  'GoCardless-Client-Library' => 'gocardless-pro-ruby',
201
- 'GoCardless-Client-Version' => '2.40.0',
211
+ 'GoCardless-Client-Version' => '2.41.0',
202
212
  },
203
213
  }
204
214
  end
@@ -28,6 +28,7 @@ module GoCardlessPro
28
28
  attr_reader :reference
29
29
  attr_reader :scheme
30
30
  attr_reader :status
31
+ attr_reader :verified_at
31
32
 
32
33
  # Initialize a mandate resource instance
33
34
  # @param object [Hash] an object returned from the API
@@ -45,6 +46,7 @@ module GoCardlessPro
45
46
  @reference = object['reference']
46
47
  @scheme = object['scheme']
47
48
  @status = object['status']
49
+ @verified_at = object['verified_at']
48
50
  @response = response
49
51
  end
50
52
 
@@ -0,0 +1,75 @@
1
+ # encoding: utf-8
2
+
3
+ #
4
+ # This client is automatically generated from a template and JSON schema definition.
5
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
6
+ #
7
+
8
+ require 'uri'
9
+
10
+ module GoCardlessPro
11
+ # A module containing classes for each of the resources in the GC Api
12
+ module Resources
13
+ # Represents an instance of a scheme_identifier resource returned from the API
14
+
15
+ # This represents a scheme identifier (e.g. a SUN in Bacs or a CID in SEPA).
16
+ # Scheme identifiers are used to specify the beneficiary name that appears
17
+ # on customers' bank statements.
18
+ #
19
+ class SchemeIdentifier
20
+ attr_reader :address_line1
21
+ attr_reader :address_line2
22
+ attr_reader :address_line3
23
+ attr_reader :can_specify_mandate_reference
24
+ attr_reader :city
25
+ attr_reader :country_code
26
+ attr_reader :created_at
27
+ attr_reader :currency
28
+ attr_reader :email
29
+ attr_reader :id
30
+ attr_reader :minimum_advance_notice
31
+ attr_reader :name
32
+ attr_reader :phone_number
33
+ attr_reader :postal_code
34
+ attr_reader :reference
35
+ attr_reader :region
36
+ attr_reader :scheme
37
+ attr_reader :status
38
+
39
+ # Initialize a scheme_identifier resource instance
40
+ # @param object [Hash] an object returned from the API
41
+ def initialize(object, response = nil)
42
+ @object = object
43
+
44
+ @address_line1 = object['address_line1']
45
+ @address_line2 = object['address_line2']
46
+ @address_line3 = object['address_line3']
47
+ @can_specify_mandate_reference = object['can_specify_mandate_reference']
48
+ @city = object['city']
49
+ @country_code = object['country_code']
50
+ @created_at = object['created_at']
51
+ @currency = object['currency']
52
+ @email = object['email']
53
+ @id = object['id']
54
+ @minimum_advance_notice = object['minimum_advance_notice']
55
+ @name = object['name']
56
+ @phone_number = object['phone_number']
57
+ @postal_code = object['postal_code']
58
+ @reference = object['reference']
59
+ @region = object['region']
60
+ @scheme = object['scheme']
61
+ @status = object['status']
62
+ @response = response
63
+ end
64
+
65
+ def api_response
66
+ ApiResponse.new(@response)
67
+ end
68
+
69
+ # Provides the scheme_identifier resource as a hash of all its readable attributes
70
+ def to_h
71
+ @object
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+
3
+ #
4
+ # This client is automatically generated from a template and JSON schema definition.
5
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
6
+ #
7
+
8
+ require 'uri'
9
+
10
+ module GoCardlessPro
11
+ # A module containing classes for each of the resources in the GC Api
12
+ module Resources
13
+ # Represents an instance of a verification_detail resource returned from the API
14
+
15
+ # Details of a creditor that are required for verification
16
+ class VerificationDetail
17
+ attr_reader :address_line1
18
+ attr_reader :address_line2
19
+ attr_reader :address_line3
20
+ attr_reader :city
21
+ attr_reader :company_number
22
+ attr_reader :description
23
+ attr_reader :directors
24
+ attr_reader :postal_code
25
+
26
+ # Initialize a verification_detail resource instance
27
+ # @param object [Hash] an object returned from the API
28
+ def initialize(object, response = nil)
29
+ @object = object
30
+
31
+ @address_line1 = object['address_line1']
32
+ @address_line2 = object['address_line2']
33
+ @address_line3 = object['address_line3']
34
+ @city = object['city']
35
+ @company_number = object['company_number']
36
+ @description = object['description']
37
+ @directors = object['directors']
38
+ @links = object['links']
39
+ @postal_code = object['postal_code']
40
+ @response = response
41
+ end
42
+
43
+ def api_response
44
+ ApiResponse.new(@response)
45
+ end
46
+
47
+ # Return the links that the resource has
48
+ def links
49
+ @verification_detail_links ||= Links.new(@links)
50
+ end
51
+
52
+ # Provides the verification_detail resource as a hash of all its readable attributes
53
+ def to_h
54
+ @object
55
+ end
56
+
57
+ class Links
58
+ def initialize(links)
59
+ @links = links || {}
60
+ end
61
+
62
+ def creditor
63
+ @links['creditor']
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -113,6 +113,50 @@ module GoCardlessPro
113
113
  Resources::Creditor.new(unenvelope_body(response.body), response)
114
114
  end
115
115
 
116
+ # Applies a [scheme identifier](#core-endpoints-scheme-identifiers) to a
117
+ # creditor.
118
+ # If the creditor already has a scheme identifier for the scheme, it will be
119
+ # replaced,
120
+ # and any mandates attached to it transferred asynchronously.
121
+ # For some schemes, the application of the scheme identifier will be performed
122
+ # asynchronously.
123
+ #
124
+ # Example URL: /creditors/:identity/actions/apply_scheme_identifier
125
+ #
126
+ # @param identity # Unique identifier, beginning with "CR".
127
+ # @param options [Hash] parameters as a hash, under a params key.
128
+ def apply_scheme_identifier(identity, options = {})
129
+ path = sub_url('/creditors/:identity/actions/apply_scheme_identifier', 'identity' => identity)
130
+
131
+ params = options.delete(:params) || {}
132
+ options[:params] = {}
133
+ options[:params]['data'] = params
134
+
135
+ options[:retry_failures] = false
136
+
137
+ begin
138
+ response = make_request(:post, path, options)
139
+
140
+ # Response doesn't raise any errors until #body is called
141
+ response.tap(&:body)
142
+ rescue InvalidStateError => e
143
+ if e.idempotent_creation_conflict?
144
+ case @api_service.on_idempotency_conflict
145
+ when :raise
146
+ raise IdempotencyConflict, e.error
147
+ when :fetch
148
+ return get(e.conflicting_resource_id)
149
+ end
150
+ end
151
+
152
+ raise e
153
+ end
154
+
155
+ return if response.body.nil?
156
+
157
+ Resources::Creditor.new(unenvelope_body(response.body), response)
158
+ end
159
+
116
160
  private
117
161
 
118
162
  # Unenvelope the response of the body using the service's `envelope_key`
@@ -0,0 +1,114 @@
1
+ require_relative './base_service'
2
+
3
+ # encoding: utf-8
4
+ #
5
+ # This client is automatically generated from a template and JSON schema definition.
6
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
7
+ #
8
+
9
+ module GoCardlessPro
10
+ module Services
11
+ # Service for making requests to the SchemeIdentifier endpoints
12
+ class SchemeIdentifiersService < BaseService
13
+ # Creates a new scheme identifier. The scheme identifier must be [applied to a
14
+ # creditor](#creditors-apply-a-scheme-identifier) before payments are taken
15
+ # using it. The scheme identifier must also have the `status` of active before
16
+ # it can be used. For some schemes e.g. faster_payments this will happen
17
+ # instantly. For other schemes e.g. bacs this can take several days.
18
+ #
19
+ # Example URL: /scheme_identifiers
20
+ # @param options [Hash] parameters as a hash, under a params key.
21
+ def create(options = {})
22
+ path = '/scheme_identifiers'
23
+
24
+ params = options.delete(:params) || {}
25
+ options[:params] = {}
26
+ options[:params][envelope_key] = params
27
+
28
+ options[:retry_failures] = true
29
+
30
+ begin
31
+ response = make_request(:post, path, options)
32
+
33
+ # Response doesn't raise any errors until #body is called
34
+ response.tap(&:body)
35
+ rescue InvalidStateError => e
36
+ if e.idempotent_creation_conflict?
37
+ case @api_service.on_idempotency_conflict
38
+ when :raise
39
+ raise IdempotencyConflict, e.error
40
+ when :fetch
41
+ return get(e.conflicting_resource_id)
42
+ end
43
+ end
44
+
45
+ raise e
46
+ end
47
+
48
+ return if response.body.nil?
49
+
50
+ Resources::SchemeIdentifier.new(unenvelope_body(response.body), response)
51
+ end
52
+
53
+ # Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your scheme
54
+ # identifiers.
55
+ # Example URL: /scheme_identifiers
56
+ # @param options [Hash] parameters as a hash, under a params key.
57
+ def list(options = {})
58
+ path = '/scheme_identifiers'
59
+
60
+ options[:retry_failures] = true
61
+
62
+ response = make_request(:get, path, options)
63
+
64
+ ListResponse.new(
65
+ response: response,
66
+ unenveloped_body: unenvelope_body(response.body),
67
+ resource_class: Resources::SchemeIdentifier
68
+ )
69
+ end
70
+
71
+ # Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
72
+ #
73
+ # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
74
+ # Otherwise they will be the body of the request.
75
+ def all(options = {})
76
+ Paginator.new(
77
+ service: self,
78
+ options: options
79
+ ).enumerator
80
+ end
81
+
82
+ # Retrieves the details of an existing scheme identifier.
83
+ # Example URL: /scheme_identifiers/:identity
84
+ #
85
+ # @param identity # Unique identifier, usually beginning with "SU".
86
+ # @param options [Hash] parameters as a hash, under a params key.
87
+ def get(identity, options = {})
88
+ path = sub_url('/scheme_identifiers/:identity', 'identity' => identity)
89
+
90
+ options[:retry_failures] = true
91
+
92
+ response = make_request(:get, path, options)
93
+
94
+ return if response.body.nil?
95
+
96
+ Resources::SchemeIdentifier.new(unenvelope_body(response.body), response)
97
+ end
98
+
99
+ private
100
+
101
+ # Unenvelope the response of the body using the service's `envelope_key`
102
+ #
103
+ # @param body [Hash]
104
+ def unenvelope_body(body)
105
+ body[envelope_key] || body['data']
106
+ end
107
+
108
+ # return the key which API responses will envelope data under
109
+ def envelope_key
110
+ 'scheme_identifiers'
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,51 @@
1
+ require_relative './base_service'
2
+
3
+ # encoding: utf-8
4
+ #
5
+ # This client is automatically generated from a template and JSON schema definition.
6
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
7
+ #
8
+
9
+ module GoCardlessPro
10
+ module Services
11
+ # Service for making requests to the VerificationDetail endpoints
12
+ class VerificationDetailsService < BaseService
13
+ # Verification details represent any information needed by GoCardless to verify
14
+ # a creditor.
15
+ # Currently, only UK-based companies are supported.
16
+ # In other words, to submit verification details for a creditor, their
17
+ # creditor_type must be company and their country_code must be GB.
18
+ # Example URL: /verification_details
19
+ # @param options [Hash] parameters as a hash, under a params key.
20
+ def create(options = {})
21
+ path = '/verification_details'
22
+
23
+ params = options.delete(:params) || {}
24
+ options[:params] = {}
25
+ options[:params][envelope_key] = params
26
+
27
+ options[:retry_failures] = true
28
+
29
+ response = make_request(:post, path, options)
30
+
31
+ return if response.body.nil?
32
+
33
+ Resources::VerificationDetail.new(unenvelope_body(response.body), response)
34
+ end
35
+
36
+ private
37
+
38
+ # Unenvelope the response of the body using the service's `envelope_key`
39
+ #
40
+ # @param body [Hash]
41
+ def unenvelope_body(body)
42
+ body[envelope_key] || body['data']
43
+ end
44
+
45
+ # return the key which API responses will envelope data under
46
+ def envelope_key
47
+ 'verification_details'
48
+ end
49
+ end
50
+ end
51
+ end
@@ -4,5 +4,5 @@ end
4
4
 
5
5
  module GoCardlessPro
6
6
  # Current version of the GC gem
7
- VERSION = '2.40.0'.freeze
7
+ VERSION = '2.41.0'.freeze
8
8
  end
@@ -119,12 +119,18 @@ require_relative 'gocardless_pro/services/refunds_service'
119
119
  require_relative 'gocardless_pro/resources/scenario_simulator'
120
120
  require_relative 'gocardless_pro/services/scenario_simulators_service'
121
121
 
122
+ require_relative 'gocardless_pro/resources/scheme_identifier'
123
+ require_relative 'gocardless_pro/services/scheme_identifiers_service'
124
+
122
125
  require_relative 'gocardless_pro/resources/subscription'
123
126
  require_relative 'gocardless_pro/services/subscriptions_service'
124
127
 
125
128
  require_relative 'gocardless_pro/resources/tax_rate'
126
129
  require_relative 'gocardless_pro/services/tax_rates_service'
127
130
 
131
+ require_relative 'gocardless_pro/resources/verification_detail'
132
+ require_relative 'gocardless_pro/services/verification_details_service'
133
+
128
134
  require_relative 'gocardless_pro/resources/webhook'
129
135
  require_relative 'gocardless_pro/services/webhooks_service'
130
136
 
@@ -562,4 +562,98 @@ describe GoCardlessPro::Resources::Creditor do
562
562
  end
563
563
  end
564
564
  end
565
+
566
+ describe '#apply_scheme_identifier' do
567
+ subject(:post_response) { client.creditors.apply_scheme_identifier(resource_id) }
568
+
569
+ let(:resource_id) { 'ABC123' }
570
+
571
+ let!(:stub) do
572
+ # /creditors/%v/actions/apply_scheme_identifier
573
+ stub_url = '/creditors/:identity/actions/apply_scheme_identifier'.gsub(':identity', resource_id)
574
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
575
+
576
+ body: {
577
+ 'creditors' => {
578
+
579
+ 'activated' => 'activated-input',
580
+ 'address_line1' => 'address_line1-input',
581
+ 'address_line2' => 'address_line2-input',
582
+ 'address_line3' => 'address_line3-input',
583
+ 'can_create_refunds' => 'can_create_refunds-input',
584
+ 'city' => 'city-input',
585
+ 'country_code' => 'country_code-input',
586
+ 'created_at' => 'created_at-input',
587
+ 'creditor_type' => 'creditor_type-input',
588
+ 'custom_payment_pages_enabled' => 'custom_payment_pages_enabled-input',
589
+ 'fx_payout_currency' => 'fx_payout_currency-input',
590
+ 'id' => 'id-input',
591
+ 'links' => 'links-input',
592
+ 'logo_url' => 'logo_url-input',
593
+ 'mandate_imports_enabled' => 'mandate_imports_enabled-input',
594
+ 'merchant_responsible_for_notifications' => 'merchant_responsible_for_notifications-input',
595
+ 'name' => 'name-input',
596
+ 'postal_code' => 'postal_code-input',
597
+ 'region' => 'region-input',
598
+ 'scheme_identifiers' => 'scheme_identifiers-input',
599
+ 'verification_status' => 'verification_status-input',
600
+ },
601
+ }.to_json,
602
+
603
+ headers: response_headers
604
+ )
605
+ end
606
+
607
+ it 'wraps the response and calls the right endpoint' do
608
+ expect(post_response).to be_a(GoCardlessPro::Resources::Creditor)
609
+
610
+ expect(stub).to have_been_requested
611
+ end
612
+
613
+ context 'when the request needs a body and custom header' do
614
+ let(:body) { { foo: 'bar' } }
615
+ let(:headers) { { 'Foo' => 'Bar' } }
616
+ subject(:post_response) { client.creditors.apply_scheme_identifier(resource_id, body, headers) }
617
+
618
+ let(:resource_id) { 'ABC123' }
619
+
620
+ let!(:stub) do
621
+ # /creditors/%v/actions/apply_scheme_identifier
622
+ stub_url = '/creditors/:identity/actions/apply_scheme_identifier'.gsub(':identity', resource_id)
623
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
624
+ with(
625
+ body: { foo: 'bar' },
626
+ headers: { 'Foo' => 'Bar' }
627
+ ).to_return(
628
+ body: {
629
+ 'creditors' => {
630
+
631
+ 'activated' => 'activated-input',
632
+ 'address_line1' => 'address_line1-input',
633
+ 'address_line2' => 'address_line2-input',
634
+ 'address_line3' => 'address_line3-input',
635
+ 'can_create_refunds' => 'can_create_refunds-input',
636
+ 'city' => 'city-input',
637
+ 'country_code' => 'country_code-input',
638
+ 'created_at' => 'created_at-input',
639
+ 'creditor_type' => 'creditor_type-input',
640
+ 'custom_payment_pages_enabled' => 'custom_payment_pages_enabled-input',
641
+ 'fx_payout_currency' => 'fx_payout_currency-input',
642
+ 'id' => 'id-input',
643
+ 'links' => 'links-input',
644
+ 'logo_url' => 'logo_url-input',
645
+ 'mandate_imports_enabled' => 'mandate_imports_enabled-input',
646
+ 'merchant_responsible_for_notifications' => 'merchant_responsible_for_notifications-input',
647
+ 'name' => 'name-input',
648
+ 'postal_code' => 'postal_code-input',
649
+ 'region' => 'region-input',
650
+ 'scheme_identifiers' => 'scheme_identifiers-input',
651
+ 'verification_status' => 'verification_status-input',
652
+ },
653
+ }.to_json,
654
+ headers: response_headers
655
+ )
656
+ end
657
+ end
658
+ end
565
659
  end