Class: Printavo::Resources::Statuses
- Defined in:
- lib/printavo/resources/statuses.rb
Constant Summary collapse
- ALL_QUERY =
File.read(File.join(__dir__, '../graphql/statuses/all.graphql')).freeze
- FIND_QUERY =
File.read(File.join(__dir__, '../graphql/statuses/find.graphql')).freeze
Instance Method Summary collapse
- #all(first: 100, after: nil) ⇒ Object
- #find(id) ⇒ Object
-
#registry ⇒ Object
Returns a Hash=> Status keyed by Status#key for O(1) lookup.
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: 100, after: nil) ⇒ Object
10 11 12 |
# File 'lib/printavo/resources/statuses.rb', line 10 def all(first: 100, after: nil) fetch_page(first: first, after: after).records end |
#find(id) ⇒ Object
14 15 16 17 |
# File 'lib/printavo/resources/statuses.rb', line 14 def find(id) data = @graphql.query(FIND_QUERY, variables: { id: id.to_s }) Printavo::Status.new(data['status']) end |
#registry ⇒ Object
Returns a Hash=> Status keyed by Status#key for O(1) lookup. Pairs with Order#status_key:
registry = client.statuses.registry
registry[order.status_key] #=> <Printavo::Status>
23 24 25 |
# File 'lib/printavo/resources/statuses.rb', line 23 def registry all.to_h { |status| [status.key, status] } end |