Skip to content

Commit

Permalink
Merge pull request #121 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Template changes
  • Loading branch information
hjheath authored Sep 25, 2023
2 parents 05b73d9 + e9adbb7 commit 114e88b
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 98 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ For POST and PUT requests you need to pass in the body in under the `params` key

When creating a resource, the library will automatically include a randomly-generated
[idempotency key](https://developer.gocardless.com/api-reference/#making-requests-idempotency-keys)
- this means that if a request appears to fail but is in fact successful (for example due
- This means that if a request appears to fail but is in fact successful (for example due
to a timeout), you will not end up creating multiple duplicates of the resource.
- By default if a request results in an Idempotency Key conflict
the library will make a second request and return the object that was
originally created with the Idempotency Key. If you wish, you can instead configure
the client to raise the conflict for you to handle. e.g
```
```rb
@client = GoCardlessPro::Client.new(
access_token: ENV["GOCARDLESS_TOKEN"],
on_idempotency_conflict: :raise,
Expand Down
2 changes: 1 addition & 1 deletion lib/gocardless_pro/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def default_options
'User-Agent' => "#{user_agent}",
'Content-Type' => 'application/json',
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
'GoCardless-Client-Version' => '2.48.0',
'GoCardless-Client-Version' => '2.49.0',
},
}
end
Expand Down
2 changes: 2 additions & 0 deletions lib/gocardless_pro/resources/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Event
attr_reader :details
attr_reader :id
attr_reader :metadata
attr_reader :resource_metadata
attr_reader :resource_type

# Initialize a event resource instance
Expand All @@ -37,6 +38,7 @@ def initialize(object, response = nil)
@id = object['id']
@links = object['links']
@metadata = object['metadata']
@resource_metadata = object['resource_metadata']
@resource_type = object['resource_type']
@response = response
end
Expand Down
2 changes: 2 additions & 0 deletions lib/gocardless_pro/resources/mandate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Mandate
attr_reader :authorisation_source
attr_reader :consent_parameters
attr_reader :created_at
attr_reader :funds_settlement
attr_reader :id
attr_reader :metadata
attr_reader :next_possible_charge_date
Expand All @@ -36,6 +37,7 @@ def initialize(object, response = nil)
@authorisation_source = object['authorisation_source']
@consent_parameters = object['consent_parameters']
@created_at = object['created_at']
@funds_settlement = object['funds_settlement']
@id = object['id']
@links = object['links']
@metadata = object['metadata']
Expand Down
16 changes: 16 additions & 0 deletions lib/gocardless_pro/resources/mandate_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def initialize(object, response = nil)

@created_at = object['created_at']
@id = object['id']
@links = object['links']
@scheme = object['scheme']
@status = object['status']
@response = response
Expand All @@ -74,10 +75,25 @@ def api_response
ApiResponse.new(@response)
end

# Return the links that the resource has
def links
@mandate_import_links ||= Links.new(@links)
end

# Provides the mandate_import resource as a hash of all its readable attributes
def to_h
@object
end

class Links
def initialize(links)
@links = links || {}
end

def creditor
@links['creditor']
end
end
end
end
end
6 changes: 0 additions & 6 deletions lib/gocardless_pro/resources/negative_balance_limit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,21 @@ module Resources
# changed on a per-creditor basis.
#
class NegativeBalanceLimit
attr_reader :active
attr_reader :balance_limit
attr_reader :created_at
attr_reader :currency
attr_reader :id
attr_reader :reason
attr_reader :updated_at

# Initialize a negative_balance_limit resource instance
# @param object [Hash] an object returned from the API
def initialize(object, response = nil)
@object = object

@active = object['active']
@balance_limit = object['balance_limit']
@created_at = object['created_at']
@currency = object['currency']
@id = object['id']
@links = object['links']
@reason = object['reason']
@updated_at = object['updated_at']
@response = response
end

Expand Down
7 changes: 3 additions & 4 deletions lib/gocardless_pro/resources/redirect_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ module Resources
# Represents an instance of a redirect_flow resource returned from the API

# <p class="deprecated-notice"><strong>Deprecated</strong>: Redirect Flows
# are our legacy APIs for setting up
# mandates and will no longer be supported in the future. We strongly
# recommend using the
# [Billing Request flow](#billing-requests) instead.</p>
# are legacy APIs and cannot be used by new integrators.
# The [Billing Request flow](#billing-requests) API should be used for
# your payment flows.</p>
#
# Redirect flows enable you to use GoCardless' [hosted payment
# pages](https://pay-sandbox.gocardless.com/AL000000AKFPFF) to set up
Expand Down
7 changes: 0 additions & 7 deletions lib/gocardless_pro/services/institutions_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ module Services
# Service for making requests to the Institution endpoints
class InstitutionsService < BaseService
# Returns a list of supported institutions.
#
# <p class="deprecated-notice"><strong>Deprecated</strong>: This list
# institutions endpoint
# is no longer supported. We strongly recommend using the
# [List Institutions For Billing
# Request](#institutions-list-institutions-for-billing-request)
# instead.</p>
# Example URL: /institutions
# @param options [Hash] parameters as a hash, under a params key.
def list(options = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def all(options = {})
).enumerator
end

# Creates a new negative balance limit, which also deactivates the existing
# limit (if present) for that currency and creditor combination.
# Creates a new negative balance limit, which replaces the existing limit (if
# present) for that currency and creditor combination.
#
# Example URL: /negative_balance_limits
# @param options [Hash] parameters as a hash, under a params key.
def create(options = {})
Expand Down
3 changes: 1 addition & 2 deletions lib/gocardless_pro/services/scenario_simulators_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ class ScenarioSimulatorsService < BaseService
# through `transferred` and resubmits it to the banks, can be caused be
# the UK's Current Account Switching Service (CASS) or when a customer
# contacts GoCardless to change their bank details. It must start in the
# `pending_submission` state. Only compatible with Bacs, SEPA and Autogiro
# mandates.</li>
# `pending_submission` state. Only compatible with Bacs mandates.</li>
# <li>`mandate_suspended_by_payer`: Transitions a mandate to
# `suspended_by_payer`, as if payer has suspended the mandate after it has
# been setup successfully. It must start in the `activated` state. Only
Expand Down
16 changes: 9 additions & 7 deletions lib/gocardless_pro/services/scheme_identifiers_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ module GoCardlessPro
module Services
# Service for making requests to the SchemeIdentifier endpoints
class SchemeIdentifiersService < BaseService
# Creates a new scheme identifier. The scheme identifier must be
# [applied to a creditor](#creditors-apply-a-scheme-identifier) before payments
# are taken
# using it. The scheme identifier must also have the `status` of active before
# it can be
# used. On Bacs, this will take 5 working days. On other schemes, this happens
# instantly.
# Creates a new scheme identifier. The scheme identifier status will be
# `pending` while GoCardless is
# processing the request. Once the scheme identifier is ready to be used the
# status will be updated to `active`.
# At this point, GoCardless will emit a scheme identifier activated event via
# webhook to notify you of this change.
# In Bacs, it will take up to five working days for a scheme identifier to
# become active. On other schemes, including SEPA,
# this happens instantly.
#
# #### Scheme identifier name validations
#
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 = '2.48.0'
VERSION = '2.49.0'
end
7 changes: 7 additions & 0 deletions spec/resources/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
'resource_type' => 'resource_type-input',
}],
meta: {
Expand Down Expand Up @@ -53,6 +54,8 @@

expect(get_list_response.records.first.metadata).to eq('metadata-input')

expect(get_list_response.records.first.resource_metadata).to eq('resource_metadata-input')

expect(get_list_response.records.first.resource_type).to eq('resource_type-input')
end

Expand All @@ -78,6 +81,7 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
'resource_type' => 'resource_type-input',
}],
meta: {
Expand All @@ -101,6 +105,7 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
'resource_type' => 'resource_type-input',
}],
meta: {
Expand Down Expand Up @@ -140,6 +145,7 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
'resource_type' => 'resource_type-input',
},
}.to_json,
Expand Down Expand Up @@ -173,6 +179,7 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
'resource_type' => 'resource_type-input',
},
}.to_json,
Expand Down
11 changes: 11 additions & 0 deletions spec/resources/mandate_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
}
Expand All @@ -30,6 +31,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand All @@ -43,6 +45,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand Down Expand Up @@ -89,6 +92,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
}
Expand Down Expand Up @@ -125,6 +129,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand Down Expand Up @@ -157,6 +162,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand Down Expand Up @@ -186,6 +192,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand Down Expand Up @@ -236,6 +243,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand Down Expand Up @@ -271,6 +279,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand All @@ -295,6 +304,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand Down Expand Up @@ -330,6 +340,7 @@

'created_at' => 'created_at-input',
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
},
Expand Down
Loading

0 comments on commit 114e88b

Please sign in to comment.