Class: SlimpayClient::RecurrentCardTransaction

Inherits:
Resource
  • Object
show all
Defined in:
lib/slimpay_client/recurrent_card_transaction.rb

Overview

An abstract CardAlias to be inherited from.

Defines API CardAlias non-semantic methods.

Instance Method Summary collapse

Methods inherited from Base

#generate_api_methods

Constructor Details

#initializeRecurrentCardTransaction

Returns a new instance of RecurrentCardTransaction.



6
7
8
9
# File 'lib/slimpay_client/recurrent_card_transaction.rb', line 6

def initialize
  @resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize
  super
end

Instance Method Details

#cancel(id = 'card-transac-1') ⇒ Object



18
19
20
21
22
23
# File 'lib/slimpay_client/recurrent_card_transaction.rb', line 18

def cancel(id = 'card-transac-1')
  url = "recurrent-card-transactions/#{id}/cancellation"
  body_options = {}
  response = HTTParty.post("#{@endpoint}/#{url}", body: body_options.to_json, headers: options)
  follow_up_api(response)
end

#get_one(id = 1) ⇒ Object



11
12
13
14
15
16
# File 'lib/slimpay_client/recurrent_card_transaction.rb', line 11

def get_one(id = 1)
  url = "#{@endpoint}/recurrent_card_transaction/#{id}"
  response = HTTParty.get(url, headers: options)
  generate_api_methods(JSON.parse(response.body))
  SlimpayClient.answer(response)
end