Class: ShopifyAPI::Collection

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

Returns a new instance of Collection.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 16

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

  @title = T.let(nil, T.nilable(String))
  @body_html = T.let(nil, T.nilable(String))
  @handle = T.let(nil, T.nilable(String))
  @id = T.let(nil, T.nilable(Integer))
  @image = T.let(nil, T.nilable(Image))
  @published_at = T.let(nil, T.nilable(String))
  @published_scope = T.let(nil, T.nilable(String))
  @sort_order = T.let(nil, T.nilable(String))
  @template_suffix = T.let(nil, T.nilable(String))
  @updated_at = T.let(nil, T.nilable(String))
end

Dynamic Method Handling

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

Instance Attribute Details

#body_htmlObject (readonly)

Returns the value of attribute body_html.



43
44
45
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 43

def body_html
  @body_html
end

#handleObject (readonly)

Returns the value of attribute handle.



45
46
47
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 45

def handle
  @handle
end

#idObject (readonly)

Returns the value of attribute id.



47
48
49
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 47

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image.



49
50
51
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 49

def image
  @image
end

#published_atObject (readonly)

Returns the value of attribute published_at.



51
52
53
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 51

def published_at
  @published_at
end

#published_scopeObject (readonly)

Returns the value of attribute published_scope.



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

def published_scope
  @published_scope
end

#sort_orderObject (readonly)

Returns the value of attribute sort_order.



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

def sort_order
  @sort_order
end

#template_suffixObject (readonly)

Returns the value of attribute template_suffix.



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

def template_suffix
  @template_suffix
end

#titleObject (readonly)

Returns the value of attribute title.



41
42
43
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 41

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Class Method Details

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



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 69

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

.products(id:, limit: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/shopify_api/rest/resources/2022_04/collection.rb', line 90

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