Class: Esignatur::Order
- Inherits:
-
Object
- Object
- Esignatur::Order
- Includes:
- ApiResource
- Defined in:
- lib/esignatur/order.rb
Overview
esignatur order representation More info: api.esignatur.dk/Documentation/Order
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #cancel ⇒ Object
- #create(attributes) ⇒ Object
- #id ⇒ Object
-
#initialize(attributes: {}, api:) ⇒ Order
constructor
A new instance of Order.
- #pades ⇒ Object
- #status ⇒ Object
Methods included from ApiResource
Constructor Details
#initialize(attributes: {}, api:) ⇒ Order
Returns a new instance of Order.
16 17 18 19 |
# File 'lib/esignatur/order.rb', line 16 def initialize(attributes: {}, api:) @attributes = attributes @api = api end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
14 15 16 |
# File 'lib/esignatur/order.rb', line 14 def attributes @attributes end |
Instance Method Details
#cancel ⇒ Object
38 39 40 |
# File 'lib/esignatur/order.rb', line 38 def cancel api_get("Order/Cancel/#{id}").success? end |
#create(attributes) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/esignatur/order.rb', line 21 def create(attributes) response = api_post('Order/Create', attributes) if errors.empty? body = response.json_body @attributes = attributes.merge(id: body.fetch('OrderId')).merge(body) end self end |
#id ⇒ Object
30 31 32 |
# File 'lib/esignatur/order.rb', line 30 def id attributes[:id] end |
#pades ⇒ Object
42 43 44 |
# File 'lib/esignatur/order.rb', line 42 def pades @pades ||= Esignatur::Pades.new(order: self, api: api) end |
#status ⇒ Object
34 35 36 |
# File 'lib/esignatur/order.rb', line 34 def status @status ||= Esignatur::Status.new(order: self, api: api).tap(&:fetch) end |