Class: Printavo::Resources::TransactionPayments

Inherits:
Base
  • Object
show all
Defined in:
lib/printavo/resources/transaction_payments.rb

Constant Summary collapse

CREATE_MUTATION =
File.read(File.join(__dir__, '../graphql/transaction_payments/create.graphql')).freeze
UPDATE_MUTATION =
File.read(File.join(__dir__, '../graphql/transaction_payments/update.graphql')).freeze
DELETE_MUTATION =
File.read(File.join(__dir__, '../graphql/transaction_payments/delete.graphql')).freeze

Instance Method Summary collapse

Methods inherited from Base

#all_pages, #each_page, #initialize

Constructor Details

This class inherits a constructor from Printavo::Resources::Base

Instance Method Details

#create(**input) ⇒ Object



11
12
13
14
# File 'lib/printavo/resources/transaction_payments.rb', line 11

def create(**input)
  data = @graphql.mutate(CREATE_MUTATION, variables: { input: camelize_keys(input) })
  Printavo::TransactionPayment.new(data['transactionPaymentCreate'])
end

#delete(id) ⇒ Object

Deletes a transaction payment. Raises on failure; returns nil on success.



23
24
25
26
# File 'lib/printavo/resources/transaction_payments.rb', line 23

def delete(id)
  @graphql.mutate(DELETE_MUTATION, variables: { id: id.to_s })
  nil
end

#update(id, **input) ⇒ Object



16
17
18
19
20
# File 'lib/printavo/resources/transaction_payments.rb', line 16

def update(id, **input)
  data = @graphql.mutate(UPDATE_MUTATION,
                         variables: { id: id.to_s, input: camelize_keys(input) })
  Printavo::TransactionPayment.new(data['transactionPaymentUpdate'])
end