Skip to content

Commit

Permalink
Merge pull request #133 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Template changes
  • Loading branch information
barrucadu authored Jan 28, 2025
2 parents a8dc279 + 22f7055 commit 6f52b3e
Show file tree
Hide file tree
Showing 8 changed files with 909 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/gocardless_pro/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def default_options
'User-Agent' => "#{user_agent}",
'Content-Type' => 'application/json',
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
'GoCardless-Client-Version' => '3.1.0'
'GoCardless-Client-Version' => '3.2.0'
}
}
end
Expand Down
3 changes: 2 additions & 1 deletion lib/gocardless_pro/resources/mandate_import_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module Resources
# href="mailto:[email protected]">get in touch</a> if you would like to
# use this API.</p>
class MandateImportEntry
attr_reader :created_at, :record_identifier
attr_reader :created_at, :processing_errors, :record_identifier

# Initialize a mandate_import_entry resource instance
# @param object [Hash] an object returned from the API
Expand All @@ -50,6 +50,7 @@ def initialize(object, response = nil)

@created_at = object['created_at']
@links = object['links']
@processing_errors = object['processing_errors']
@record_identifier = object['record_identifier']
@response = response
end
Expand Down
75 changes: 73 additions & 2 deletions lib/gocardless_pro/services/billing_requests_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ module Services
# Service for making requests to the BillingRequest endpoints
class BillingRequestsService < BaseService
# <p class="notice"><strong>Important</strong>: All properties associated with
# `subscription_request` and `instalment_schedule_request` are only supported
# for ACH and PAD schemes.</p>
# `subscription_request` are only supported for ACH and PAD schemes.</p>
# Example URL: /billing_requests
# @param options [Hash] parameters as a hash, under a params key.
def create(options = {})
Expand Down Expand Up @@ -47,6 +46,78 @@ def create(options = {})
Resources::BillingRequest.new(unenvelope_body(response.body), response)
end

# <p class="notice"><strong>Important</strong>: All properties associated with
# `instalment_schedule_request` are only supported for ACH and PAD schemes.</p>
# Example URL: /billing_requests
# @param options [Hash] parameters as a hash, under a params key.
def create_with_instalments_with_dates(options = {})
path = '/billing_requests'

params = options.delete(:params) || {}
options[:params] = {}
options[:params][envelope_key] = params

options[:retry_failures] = true

begin
response = make_request(:post, path, options)

# Response doesn't raise any errors until #body is called
response.tap(&:body)
rescue InvalidStateError => e
if e.idempotent_creation_conflict?
case @api_service.on_idempotency_conflict
when :raise
raise IdempotencyConflict, e.error
when :fetch
return get(e.conflicting_resource_id)
end
end

raise e
end

return if response.body.nil?

Resources::BillingRequest.new(unenvelope_body(response.body), response)
end

# <p class="notice"><strong>Important</strong>: All properties associated with
# `instalment_schedule_request` are only supported for ACH and PAD schemes.</p>
# Example URL: /billing_requests
# @param options [Hash] parameters as a hash, under a params key.
def create_with_instalments_with_schedule(options = {})
path = '/billing_requests'

params = options.delete(:params) || {}
options[:params] = {}
options[:params][envelope_key] = params

options[:retry_failures] = true

begin
response = make_request(:post, path, options)

# Response doesn't raise any errors until #body is called
response.tap(&:body)
rescue InvalidStateError => e
if e.idempotent_creation_conflict?
case @api_service.on_idempotency_conflict
when :raise
raise IdempotencyConflict, e.error
when :fetch
return get(e.conflicting_resource_id)
end
end

raise e
end

return if response.body.nil?

Resources::BillingRequest.new(unenvelope_body(response.body), response)
end

# If the billing request has a pending <code>collect_customer_details</code>
# action, this endpoint can be used to collect the details in order to
# complete it.
Expand Down
2 changes: 1 addition & 1 deletion lib/gocardless_pro/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module GoCardlessPro

module GoCardlessPro
# Current version of the GC gem
VERSION = '3.1.0'
VERSION = '3.2.0'
end
Loading

0 comments on commit 6f52b3e

Please sign in to comment.