Class: ShopifyAPI::GiftCard

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


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 12

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(Float))
  @code = T.let(nil, T.nilable(String))
  @created_at = T.let(nil, T.nilable(String))
  @currency = T.let(nil, T.nilable(String))
  @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(Float))
  @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.


47
48
49
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 47

def api_client_id
  @api_client_id
end

#balanceObject (readonly)

Returns the value of attribute balance.


49
50
51
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 49

def balance
  @balance
end

#codeObject (readonly)

Returns the value of attribute code.


51
52
53
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 51

def code
  @code
end

#created_atObject (readonly)

Returns the value of attribute created_at.


53
54
55
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 53

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.


55
56
57
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 55

def currency
  @currency
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.


57
58
59
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 57

def customer_id
  @customer_id
end

#disabled_atObject (readonly)

Returns the value of attribute disabled_at.


59
60
61
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 59

def disabled_at
  @disabled_at
end

#expires_onObject (readonly)

Returns the value of attribute expires_on.


61
62
63
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 61

def expires_on
  @expires_on
end

#idObject (readonly)

Returns the value of attribute id.


63
64
65
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 63

def id
  @id
end

#initial_valueObject (readonly)

Returns the value of attribute initial_value.


65
66
67
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 65

def initial_value
  @initial_value
end

#last_charactersObject (readonly)

Returns the value of attribute last_characters.


67
68
69
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 67

def last_characters
  @last_characters
end

#line_item_idObject (readonly)

Returns the value of attribute line_item_id.


69
70
71
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 69

def line_item_id
  @line_item_id
end

#noteObject (readonly)

Returns the value of attribute note.


71
72
73
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 71

def note
  @note
end

#order_idObject (readonly)

Returns the value of attribute order_id.


73
74
75
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 73

def order_id
  @order_id
end

#template_suffixObject (readonly)

Returns the value of attribute template_suffix.


75
76
77
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 75

def template_suffix
  @template_suffix
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.


77
78
79
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 77

def updated_at
  @updated_at
end

#user_idObject (readonly)

Returns the value of attribute user_id.


79
80
81
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 79

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


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 110

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


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 134

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


88
89
90
91
92
93
94
95
96
97
98
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 88

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, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 160

def search(
  order: nil,
  query: nil,
  limit: nil,
  fields: 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}.merge(kwargs).compact,
    body: {},
    entity: nil,
  )
end

Instance Method Details

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


187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/shopify_api/rest/resources/2021_07/gift_card.rb', line 187

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