Skip to content

Commit

Permalink
Changes from gocardless/gocardless-pro-ruby-template@1270f620323edfc0…
Browse files Browse the repository at this point in the history
…e45fb145cbf45a92fd5d0529
  • Loading branch information
gocardless-robot committed May 17, 2024
1 parent ab7af9b commit 34f85e9
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/gocardless_pro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ module GoCardlessPro
require_relative 'gocardless_pro/resources/institution'
require_relative 'gocardless_pro/services/institutions_service'

require_relative 'gocardless_pro/resources/logo'
require_relative 'gocardless_pro/services/logos_service'

require_relative 'gocardless_pro/resources/mandate'
require_relative 'gocardless_pro/services/mandates_service'

Expand Down
5 changes: 5 additions & 0 deletions lib/gocardless_pro/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def institutions
@institutions ||= Services::InstitutionsService.new(@api_service)
end

# Access to the service for logo to make API calls
def logos
@logos ||= Services::LogosService.new(@api_service)
end

# Access to the service for mandate to make API calls
def mandates
@mandates ||= Services::MandatesService.new(@api_service)
Expand Down
38 changes: 38 additions & 0 deletions lib/gocardless_pro/resources/logo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
#

require 'uri'

module GoCardlessPro
# A module containing classes for each of the resources in the GC Api
module Resources
# Represents an instance of a logo resource returned from the API

# Logos are image uploads that, when associated with a creditor, are shown
# on the [billing request flow](#billing-requests-billing-request-flows)
# payment pages.
class Logo
attr_reader :id

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

@id = object['id']
@response = response
end

def api_response
ApiResponse.new(@response)
end

# Provides the logo resource as a hash of all its readable attributes
def to_h
@object
end
end
end
end
28 changes: 28 additions & 0 deletions lib/gocardless_pro/services/logos_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require_relative './base_service'

# encoding: utf-8
#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
#

module GoCardlessPro
module Services
# Service for making requests to the Logo endpoints
class LogosService < BaseService
private

# Unenvelope the response of the body using the service's `envelope_key`
#
# @param body [Hash]
def unenvelope_body(body)
body[envelope_key] || body['data']
end

# return the key which API responses will envelope data under
def envelope_key
'logos'
end
end
end
end
11 changes: 11 additions & 0 deletions spec/resources/logo_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

describe GoCardlessPro::Resources::Logo do
let(:client) do
GoCardlessPro::Client.new(
access_token: 'SECRET_TOKEN'
)
end

let(:response_headers) { { 'Content-Type' => 'application/json' } }
end
11 changes: 11 additions & 0 deletions spec/services/logos_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

describe GoCardlessPro::Services::LogosService do
let(:client) do
GoCardlessPro::Client.new(
access_token: 'SECRET_TOKEN'
)
end

let(:response_headers) { { 'Content-Type' => 'application/json' } }
end

0 comments on commit 34f85e9

Please sign in to comment.