Class: ShopifyAPI::DraftOrder

Inherits:
Rest::Base show all
Extended by:
T::Sig
Defined in:
lib/shopify_api/rest/resources/2022_04/draft_order.rb,
lib/shopify_api/rest/resources/2022_07/draft_order.rb,
lib/shopify_api/rest/resources/2022_10/draft_order.rb,
lib/shopify_api/rest/resources/2023_01/draft_order.rb,
lib/shopify_api/rest/resources/2023_04/draft_order.rb,
lib/shopify_api/rest/resources/2023_07/draft_order.rb,
lib/shopify_api/rest/resources/2023_10/draft_order.rb,
lib/shopify_api/rest/resources/2024_01/draft_order.rb,
lib/shopify_api/rest/resources/2024_04/draft_order.rb,
lib/shopify_api/rest/resources/2024_07/draft_order.rb,
lib/shopify_api/rest/resources/2024_10/draft_order.rb

Instance Attribute Summary collapse

Attributes inherited from Rest::Base

#errors, #original_state

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rest::Base

api_call_limit, base_find, class_name, create_instance, create_instances_from_response, #delete, get_path, get_path_ids, has_many?, has_one?, inherited, json_body_name, json_response_body_names, #method_missing, next_page?, next_page_info, prev_page?, prev_page_info, primary_key, read_only_attributes, request, #respond_to_missing?, retry_request_after, #save, #save!, #to_hash

Constructor Details

#initialize(session: ShopifyAPI::Context.active_session, from_hash: nil) ⇒ DraftOrder

Returns a new instance of DraftOrder.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 19

def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)

  @applied_discount = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @billing_address = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @completed_at = T.let(nil, T.nilable(String))
  @created_at = T.let(nil, T.nilable(String))
  @currency = T.let(nil, T.nilable(String))
  @customer = T.let(nil, T.nilable(Customer))
  @email = T.let(nil, T.nilable(String))
  @id = T.let(nil, T.nilable(Integer))
  @invoice_sent_at = T.let(nil, T.nilable(String))
  @invoice_url = T.let(nil, T.nilable(String))
  @line_items = T.let(nil, T.nilable(T::Array[T.untyped]))
  @name = T.let(nil, T.nilable(String))
  @note = T.let(nil, T.nilable(String))
  @note_attributes = T.let(nil, T.nilable(T::Array[T.untyped]))
  @order_id = T.let(nil, T.nilable(Integer))
  @payment_terms = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @shipping_address = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @shipping_line = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @source_name = T.let(nil, T.nilable(String))
  @status = T.let(nil, T.nilable(String))
  @subtotal_price = T.let(nil, T.nilable(String))
  @tags = T.let(nil, T.nilable(String))
  @tax_exempt = T.let(nil, T.nilable(T::Boolean))
  @tax_exemptions = T.let(nil, T.nilable(T::Array[T.untyped]))
  @tax_lines = T.let(nil, T.nilable(T::Array[T.untyped]))
  @taxes_included = T.let(nil, T.nilable(T::Boolean))
  @total_price = T.let(nil, T.nilable(String))
  @total_tax = T.let(nil, T.nilable(String))
  @updated_at = T.let(nil, T.nilable(String))

  super(session: session, from_hash: from_hash)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ShopifyAPI::Rest::Base

Instance Attribute Details

#applied_discountObject (readonly)

Returns the value of attribute applied_discount.



70
71
72
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 70

def applied_discount
  @applied_discount
end

#billing_addressObject (readonly)

Returns the value of attribute billing_address.



72
73
74
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 72

def billing_address
  @billing_address
end

#completed_atObject (readonly)

Returns the value of attribute completed_at.



74
75
76
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 74

def completed_at
  @completed_at
end

#created_atObject (readonly)

Returns the value of attribute created_at.



76
77
78
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 76

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



78
79
80
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 78

def currency
  @currency
end

#customerObject (readonly)

Returns the value of attribute customer.



80
81
82
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 80

def customer
  @customer
end

#emailObject (readonly)

Returns the value of attribute email.



82
83
84
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 82

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



84
85
86
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 84

def id
  @id
end

#invoice_sent_atObject (readonly)

Returns the value of attribute invoice_sent_at.



86
87
88
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 86

def invoice_sent_at
  @invoice_sent_at
end

#invoice_urlObject (readonly)

Returns the value of attribute invoice_url.



88
89
90
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 88

def invoice_url
  @invoice_url
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



90
91
92
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 90

def line_items
  @line_items
end

#nameObject (readonly)

Returns the value of attribute name.



92
93
94
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 92

def name
  @name
end

#noteObject (readonly)

Returns the value of attribute note.



94
95
96
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 94

def note
  @note
end

#note_attributesObject (readonly)

Returns the value of attribute note_attributes.



96
97
98
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 96

def note_attributes
  @note_attributes
end

#order_idObject (readonly)

Returns the value of attribute order_id.



98
99
100
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 98

def order_id
  @order_id
end

#payment_termsObject (readonly)

Returns the value of attribute payment_terms.



100
101
102
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 100

def payment_terms
  @payment_terms
end

#shipping_addressObject (readonly)

Returns the value of attribute shipping_address.



102
103
104
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 102

def shipping_address
  @shipping_address
end

#shipping_lineObject (readonly)

Returns the value of attribute shipping_line.



104
105
106
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 104

def shipping_line
  @shipping_line
end

#source_nameObject (readonly)

Returns the value of attribute source_name.



106
107
108
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 106

def source_name
  @source_name
end

#statusObject (readonly)

Returns the value of attribute status.



108
109
110
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 108

def status
  @status
end

#subtotal_priceObject (readonly)

Returns the value of attribute subtotal_price.



110
111
112
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 110

def subtotal_price
  @subtotal_price
end

#tagsObject (readonly)

Returns the value of attribute tags.



112
113
114
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 112

def tags
  @tags
end

#tax_exemptObject (readonly)

Returns the value of attribute tax_exempt.



114
115
116
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 114

def tax_exempt
  @tax_exempt
end

#tax_exemptionsObject (readonly)

Returns the value of attribute tax_exemptions.



116
117
118
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 116

def tax_exemptions
  @tax_exemptions
end

#tax_linesObject (readonly)

Returns the value of attribute tax_lines.



118
119
120
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 118

def tax_lines
  @tax_lines
end

#taxes_includedObject (readonly)

Returns the value of attribute taxes_included.



120
121
122
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 120

def taxes_included
  @taxes_included
end

#total_priceObject (readonly)

Returns the value of attribute total_price.



122
123
124
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 122

def total_price
  @total_price
end

#total_taxObject (readonly)

Returns the value of attribute total_tax.



124
125
126
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 124

def total_tax
  @total_tax
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



126
127
128
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 126

def updated_at
  @updated_at
end

Class Method Details

.all(fields: nil, limit: nil, since_id: nil, updated_at_min: nil, updated_at_max: nil, ids: nil, status: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 181

def all(
  fields: nil,
  limit: nil,
  since_id: nil,
  updated_at_min: nil,
  updated_at_max: nil,
  ids: nil,
  status: nil,
  session: ShopifyAPI::Context.active_session,
  **kwargs
)
  response = base_find(
    session: session,
    ids: {},
    params: {fields: fields, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ids: ids, status: status}.merge(kwargs).compact,
  )

  T.cast(response, T::Array[DraftOrder])
end

.count(since_id: nil, status: nil, updated_at_max: nil, updated_at_min: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 211

def count(
  since_id: nil,
  status: nil,
  updated_at_max: nil,
  updated_at_min: nil,
  session: ShopifyAPI::Context.active_session,
  **kwargs
)
  request(
    http_method: :get,
    operation: :count,
    session: session,
    ids: {},
    params: {since_id: since_id, status: status, updated_at_max: updated_at_max, updated_at_min: updated_at_min}.merge(kwargs).compact,
    body: {},
    entity: nil,
  )
end

.delete(id:, session: ShopifyAPI::Context.active_session) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 155

def delete(
  id:,
  session: ShopifyAPI::Context.active_session
)
  request(
    http_method: :delete,
    operation: :delete,
    session: session,
    ids: {id: id},
    params: {},
  )
end

.find(id:, fields: nil, session: ShopifyAPI::Context.active_session) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 136

def find(
  id:,
  fields: nil,
  session: ShopifyAPI::Context.active_session
)
  result = base_find(
    session: session,
    ids: {id: id},
    params: {fields: fields},
  )
  T.cast(result[0], T.nilable(DraftOrder))
end

Instance Method Details

#complete(payment_gateway_id: nil, payment_pending: nil, body: nil, **kwargs) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 261

def complete(
  payment_gateway_id: nil,
  payment_pending: nil,
  body: nil,
  **kwargs
)
  self.class.request(
    http_method: :put,
    operation: :complete,
    session: @session,
    ids: {id: @id},
    params: {payment_gateway_id: payment_gateway_id, payment_pending: payment_pending}.merge(kwargs).compact,
    body: body,
    entity: self,
  )
end

#send_invoice(body: nil, **kwargs) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/shopify_api/rest/resources/2022_04/draft_order.rb', line 238

def send_invoice(
  body: nil,
  **kwargs
)
  self.class.request(
    http_method: :post,
    operation: :send_invoice,
    session: @session,
    ids: {id: @id},
    params: {}.merge(kwargs).compact,
    body: body,
    entity: self,
  )
end