Class: Printavo::Resources::Mockups

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

Constant Summary collapse

ALL_QUERY =
File.read(File.join(__dir__, '../graphql/mockups/all.graphql')).freeze
FIND_QUERY =
File.read(File.join(__dir__, '../graphql/mockups/find.graphql')).freeze
DELETE_MUTATION =
File.read(File.join(__dir__, '../graphql/mockups/delete.graphql')).freeze
DELETES_MUTATION =
File.read(File.join(__dir__, '../graphql/mockups/deletes.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(order_id:, first: 25, after: nil) ⇒ Object



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

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

#delete(id) ⇒ Object



21
22
23
24
# File 'lib/printavo/resources/mockups.rb', line 21

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

#deletes(ids) ⇒ Object



26
27
28
29
# File 'lib/printavo/resources/mockups.rb', line 26

def deletes(ids)
  @graphql.mutate(DELETES_MUTATION, variables: { ids: ids.map(&:to_s) })
  nil
end

#find(id) ⇒ Object



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

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