Class: BigCommerce::ManagementAPI::Customers

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/big_commerce/management_api/customers.rb

Defined Under Namespace

Classes: Addresses, AttributeValues, Attributes, Metafields

Constant Summary collapse

PATH =
"customers"
RESULT_INSTANCE =
Customer

Constants inherited from Endpoint

Endpoint::CONTENT_TYPE, Endpoint::CONTENT_TYPE_JSON, Endpoint::HOST, Endpoint::JSON_CONTENT_TYPES, Endpoint::PORT, Endpoint::RESULT_KEY, Endpoint::USER_AGENT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*argz) ⇒ Customers

Returns a new instance of Customers.



141
142
143
144
145
146
147
148
# File 'lib/big_commerce/management_api/customers.rb', line 141

def initialize(*argz)
  super(*argz)

  @addresses = Addresses.new(*argz)
  @attributes = Attributes.new(*argz)
  @attribute_values = AttributeValues.new(*argz)
  @metafields = Metafields.new(*argz)
end

Instance Attribute Details

#addressesObject (readonly)

Returns the value of attribute addresses.



136
137
138
# File 'lib/big_commerce/management_api/customers.rb', line 136

def addresses
  @addresses
end

#attribute_valuesObject (readonly)

Returns the value of attribute attribute_values.



136
137
138
# File 'lib/big_commerce/management_api/customers.rb', line 136

def attribute_values
  @attribute_values
end

#attributesObject (readonly)

Returns the value of attribute attributes.



136
137
138
# File 'lib/big_commerce/management_api/customers.rb', line 136

def attributes
  @attributes
end

#metafieldsObject (readonly)

Returns the value of attribute metafields.



136
137
138
# File 'lib/big_commerce/management_api/customers.rb', line 136

def metafields
  @metafields
end

Instance Method Details

#create(*customers) ⇒ Object



150
151
152
153
154
# File 'lib/big_commerce/management_api/customers.rb', line 150

def create(*customers)
  customers.flatten!

  POST(PATH, customers.map(&:to_h))
end

#delete(*ids) ⇒ Object



156
157
158
159
160
161
162
163
# File 'lib/big_commerce/management_api/customers.rb', line 156

def delete(*ids)
  ids.flatten!

  DELETE(
    PATH,
    with_in_param({:id => ids}, :id)
  )
end

#get(options = {}) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/big_commerce/management_api/customers.rb', line 165

def get(options = {})
  GET(
    PATH,
    with_in_param(
      options,
      :company,
      :customer_group_id,
      :email,
      :id,
      :name,
      :registration_ip_address
    )
  )
end

#update(*customers) ⇒ Object



180
181
182
183
184
# File 'lib/big_commerce/management_api/customers.rb', line 180

def update(*customers)
  customers.flatten!

  PUT(PATH, customers.map(&:to_h))
end