Class: Esignatur::Orders
- Inherits:
-
Object
- Object
- Esignatur::Orders
- Includes:
- Enumerable, ApiResource
- Defined in:
- lib/esignatur/orders.rb
Overview
esignatur order info collection representation. more info: api.esignatur.dk/Documentation/OrderInfo
Instance Method Summary collapse
- #all ⇒ Object
- #build ⇒ Object
- #create(attributes = {}, **keyword_attributes) ⇒ Object
- #each(&block) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(scope: {}, api:) ⇒ Orders
constructor
A new instance of Orders.
- #where(new_scope) ⇒ Object
Methods included from ApiResource
Constructor Details
#initialize(scope: {}, api:) ⇒ Orders
Returns a new instance of Orders.
12 13 14 15 |
# File 'lib/esignatur/orders.rb', line 12 def initialize(scope: {}, api:) @scope = scope @api = api end |
Instance Method Details
#all ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/esignatur/orders.rb', line 29 def all @all ||= begin response = api_get("OrderInfo/OrdersForAdministrator/#{api.creator_id}", headers: headers_for_all_query) response.json_body.fetch('SignOrders').map do |raw_order| order_attributes = raw_order.merge(id: raw_order.fetch('SignOrderId')) Esignatur::Order.new(attributes: order_attributes, api: api) end end end |
#build ⇒ Object
21 22 23 |
# File 'lib/esignatur/orders.rb', line 21 def build Esignatur::Order.new(api: api) end |
#create(attributes = {}, **keyword_attributes) ⇒ Object
17 18 19 |
# File 'lib/esignatur/orders.rb', line 17 def create(attributes = {}, **keyword_attributes) build.create(attributes, **keyword_attributes) end |
#each(&block) ⇒ Object
39 40 41 |
# File 'lib/esignatur/orders.rb', line 39 def each(&block) all.each(&block) end |
#find(id) ⇒ Object
43 44 45 |
# File 'lib/esignatur/orders.rb', line 43 def find(id) Esignatur::Order.new(attributes: { id: id }, api: api) end |
#where(new_scope) ⇒ Object
25 26 27 |
# File 'lib/esignatur/orders.rb', line 25 def where(new_scope) self.class.new(scope: scope.merge(new_scope), api: api) end |