Class: Printavo::Resources::PaymentTerms

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

Constant Summary collapse

ALL_QUERY =
File.read(File.join(__dir__, '../graphql/payment_terms/all.graphql')).freeze
FIND_QUERY =
File.read(File.join(__dir__, '../graphql/payment_terms/find.graphql')).freeze
CREATE_MUTATION =
File.read(File.join(__dir__, '../graphql/payment_terms/create.graphql')).freeze
UPDATE_MUTATION =
File.read(File.join(__dir__, '../graphql/payment_terms/update.graphql')).freeze
ARCHIVE_MUTATION =
File.read(File.join(__dir__, '../graphql/payment_terms/archive.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

#all(first: 25, after: nil) ⇒ Object



13
14
15
# File 'lib/printavo/resources/payment_terms.rb', line 13

def all(first: 25, after: nil)
  fetch_page(first: first, after: after).records
end

#archive(id) ⇒ Object



32
33
34
35
# File 'lib/printavo/resources/payment_terms.rb', line 32

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

#create(**input) ⇒ Object



22
23
24
25
# File 'lib/printavo/resources/payment_terms.rb', line 22

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

#find(id) ⇒ Object



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

def find(id)
  data = @graphql.query(FIND_QUERY, variables: { id: id.to_s })
  Printavo::PaymentTerm.new(data['paymentTerm'])
end

#update(id, **input) ⇒ Object



27
28
29
30
# File 'lib/printavo/resources/payment_terms.rb', line 27

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