Class: ShopifyAPI::GiftCard

Inherits:
Rest::Base show all
Extended by:
T::Sig
Defined in:
lib/shopify_api/rest/resources/2022_04/gift_card.rb,
lib/shopify_api/rest/resources/2022_07/gift_card.rb,
lib/shopify_api/rest/resources/2022_10/gift_card.rb,
lib/shopify_api/rest/resources/2023_01/gift_card.rb,
lib/shopify_api/rest/resources/2023_04/gift_card.rb,
lib/shopify_api/rest/resources/2023_07/gift_card.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

base_find, class_name, create_instance, create_instances_from_response, #delete, get_path, has_many?, has_one?, 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?, #save, #save!, #to_hash

Constructor Details

#initialize(session: ShopifyAPI::Context.active_session) ⇒ GiftCard

Returns a new instance of GiftCard.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 16

def initialize(session: ShopifyAPI::Context.active_session)
  super(session: session)

  @api_client_id = T.let(nil, T.nilable(Integer))
  @balance = T.let(nil, T.nilable(Balance))
  @code = T.let(nil, T.nilable(String))
  @created_at = T.let(nil, T.nilable(String))
  @currency = T.let(nil, T.nilable(Currency))
  @customer_id = T.let(nil, T.nilable(Integer))
  @disabled_at = T.let(nil, T.nilable(String))
  @expires_on = T.let(nil, T.nilable(String))
  @id = T.let(nil, T.nilable(Integer))
  @initial_value = T.let(nil, T.nilable(String))
  @last_characters = T.let(nil, T.nilable(String))
  @line_item_id = T.let(nil, T.nilable(Integer))
  @note = T.let(nil, T.nilable(String))
  @order_id = T.let(nil, T.nilable(Integer))
  @template_suffix = T.let(nil, T.nilable(String))
  @updated_at = T.let(nil, T.nilable(String))
  @user_id = T.let(nil, T.nilable(Integer))
end

Dynamic Method Handling

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

Instance Attribute Details

#api_client_idObject (readonly)

Returns the value of attribute api_client_id.



54
55
56
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 54

def api_client_id
  @api_client_id
end

#balanceObject (readonly)

Returns the value of attribute balance.



56
57
58
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 56

def balance
  @balance
end

#codeObject (readonly)

Returns the value of attribute code.



58
59
60
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 58

def code
  @code
end

#created_atObject (readonly)

Returns the value of attribute created_at.



60
61
62
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 60

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



62
63
64
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 62

def currency
  @currency
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



64
65
66
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 64

def customer_id
  @customer_id
end

#disabled_atObject (readonly)

Returns the value of attribute disabled_at.



66
67
68
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 66

def disabled_at
  @disabled_at
end

#expires_onObject (readonly)

Returns the value of attribute expires_on.



68
69
70
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 68

def expires_on
  @expires_on
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#initial_valueObject (readonly)

Returns the value of attribute initial_value.



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

def initial_value
  @initial_value
end

#last_charactersObject (readonly)

Returns the value of attribute last_characters.



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

def last_characters
  @last_characters
end

#line_item_idObject (readonly)

Returns the value of attribute line_item_id.



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

def line_item_id
  @line_item_id
end

#noteObject (readonly)

Returns the value of attribute note.



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

def note
  @note
end

#order_idObject (readonly)

Returns the value of attribute order_id.



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

def order_id
  @order_id
end

#template_suffixObject (readonly)

Returns the value of attribute template_suffix.



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

def template_suffix
  @template_suffix
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

#user_idObject (readonly)

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Class Method Details

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



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 117

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

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

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



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 141

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

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



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 95

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

.search(order: nil, query: nil, limit: nil, fields: nil, created_at_min: nil, created_at_max: nil, updated_at_min: nil, updated_at_max: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 171

def search(
  order: nil,
  query: nil,
  limit: nil,
  fields: nil,
  created_at_min: nil,
  created_at_max: nil,
  updated_at_min: nil,
  updated_at_max: nil,
  session: ShopifyAPI::Context.active_session,
  **kwargs
)
  request(
    http_method: :get,
    operation: :search,
    session: session,
    ids: {},
    params: {order: order, query: query, limit: limit, fields: fields, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max}.merge(kwargs).compact,
    body: {},
    entity: nil,
  )
end

Instance Method Details

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



202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/shopify_api/rest/resources/2022_04/gift_card.rb', line 202

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