Class: ShopifyAPI::Customer

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

Returns a new instance of Customer.



16
17
18
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
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 16

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

  @accepts_marketing = T.let(nil, T.nilable(T::Boolean))
  @accepts_marketing_updated_at = T.let(nil, T.nilable(String))
  @addresses = T.let(nil, T.nilable(T::Array[T.untyped]))
  @created_at = T.let(nil, T.nilable(String))
  @currency = T.let(nil, T.nilable(String))
  @default_address = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @email = T.let(nil, T.nilable(String))
  @first_name = T.let(nil, T.nilable(String))
  @id = T.let(nil, T.nilable(Integer))
  @last_name = T.let(nil, T.nilable(String))
  @last_order_id = T.let(nil, T.nilable(Integer))
  @last_order_name = T.let(nil, T.nilable(String))
  @marketing_opt_in_level = T.let(nil, T.nilable(String))
  @metafield = T.let(nil, T.nilable(Metafield))
  @multipass_identifier = T.let(nil, T.nilable(String))
  @note = T.let(nil, T.nilable(String))
  @orders_count = T.let(nil, T.nilable(Integer))
  @phone = T.let(nil, T.nilable(String))
  @sms_marketing_consent = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @state = 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]))
  @total_spent = T.let(nil, T.nilable(String))
  @updated_at = T.let(nil, T.nilable(String))
  @verified_email = T.let(nil, T.nilable(T::Boolean))
end

Dynamic Method Handling

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

Instance Attribute Details

#accepts_marketingObject (readonly)

Returns the value of attribute accepts_marketing.



64
65
66
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 64

def accepts_marketing
  @accepts_marketing
end

#accepts_marketing_updated_atObject (readonly)

Returns the value of attribute accepts_marketing_updated_at.



66
67
68
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 66

def accepts_marketing_updated_at
  @accepts_marketing_updated_at
end

#addressesObject (readonly)

Returns the value of attribute addresses.



68
69
70
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 68

def addresses
  @addresses
end

#created_atObject (readonly)

Returns the value of attribute created_at.



70
71
72
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 70

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



72
73
74
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 72

def currency
  @currency
end

#default_addressObject (readonly)

Returns the value of attribute default_address.



74
75
76
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 74

def default_address
  @default_address
end

#emailObject (readonly)

Returns the value of attribute email.



76
77
78
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 76

def email
  @email
end

Returns the value of attribute email_marketing_consent.



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

def email_marketing_consent
  @email_marketing_consent
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



78
79
80
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 78

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



80
81
82
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 80

def id
  @id
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



82
83
84
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 82

def last_name
  @last_name
end

#last_order_idObject (readonly)

Returns the value of attribute last_order_id.



84
85
86
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 84

def last_order_id
  @last_order_id
end

#last_order_nameObject (readonly)

Returns the value of attribute last_order_name.



86
87
88
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 86

def last_order_name
  @last_order_name
end

#marketing_opt_in_levelObject (readonly)

Returns the value of attribute marketing_opt_in_level.



88
89
90
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 88

def marketing_opt_in_level
  @marketing_opt_in_level
end

#metafieldObject (readonly)

Returns the value of attribute metafield.



90
91
92
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 90

def metafield
  @metafield
end

#multipass_identifierObject (readonly)

Returns the value of attribute multipass_identifier.



92
93
94
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 92

def multipass_identifier
  @multipass_identifier
end

#noteObject (readonly)

Returns the value of attribute note.



94
95
96
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 94

def note
  @note
end

#orders_countObject (readonly)

Returns the value of attribute orders_count.



96
97
98
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 96

def orders_count
  @orders_count
end

#passwordObject (readonly)

Returns the value of attribute password.



103
104
105
# File 'lib/shopify_api/rest/resources/2022_07/customer.rb', line 103

def password
  @password
end

#password_confirmationObject (readonly)

Returns the value of attribute password_confirmation.



105
106
107
# File 'lib/shopify_api/rest/resources/2022_07/customer.rb', line 105

def password_confirmation
  @password_confirmation
end

#phoneObject (readonly)

Returns the value of attribute phone.



98
99
100
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 98

def phone
  @phone
end

Returns the value of attribute sms_marketing_consent.



100
101
102
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 100

def sms_marketing_consent
  @sms_marketing_consent
end

#stateObject (readonly)

Returns the value of attribute state.



102
103
104
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 102

def state
  @state
end

#tagsObject (readonly)

Returns the value of attribute tags.



104
105
106
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 104

def tags
  @tags
end

#tax_exemptObject (readonly)

Returns the value of attribute tax_exempt.



106
107
108
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 106

def tax_exempt
  @tax_exempt
end

#tax_exemptionsObject (readonly)

Returns the value of attribute tax_exemptions.



108
109
110
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 108

def tax_exemptions
  @tax_exemptions
end

#total_spentObject (readonly)

Returns the value of attribute total_spent.



110
111
112
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 110

def total_spent
  @total_spent
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



112
113
114
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 112

def updated_at
  @updated_at
end

#verified_emailObject (readonly)

Returns the value of attribute verified_email.



114
115
116
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 114

def verified_email
  @verified_email
end

Class Method Details

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



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 151

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

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

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



178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 178

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

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



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 124

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(Customer))
end

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



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 201

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

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



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 228

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

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



255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 255

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

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



276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/shopify_api/rest/resources/2021_10/customer.rb', line 276

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