Class: BigcommerceAPI::Address

Inherits:
Resource show all
Defined in:
lib/bigcommerce_api/address.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#errors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#assign_attributes, belongs_to, #changed, #create, #delete, has_many, has_one, http_request, #initialize, #mark_dirty!, #reload, #resource, resource, #save, #update_attributes

Methods inherited from Base

#attributes, clean!, date_adjust, default_options, #initialize, #store, #time, to_rfc2822

Constructor Details

This class inherits a constructor from BigcommerceAPI::Resource

Instance Attribute Details

#address_typeObject

Returns the value of attribute address_type.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def address_type
  @address_type
end

#cityObject

Returns the value of attribute city.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def city
  @city
end

#companyObject

Returns the value of attribute company.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def company
  @company
end

#countryObject

Returns the value of attribute country.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def country
  @country
end

#country_iso2Object

Returns the value of attribute country_iso2.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def country_iso2
  @country_iso2
end

#customer_idObject

Returns the value of attribute customer_id.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def customer_id
  @customer_id
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def first_name
  @first_name
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def id
  @id
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def last_name
  @last_name
end

#phoneObject

Returns the value of attribute phone.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def phone
  @phone
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def state
  @state
end

#street_1Object

Returns the value of attribute street_1.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def street_1
  @street_1
end

#street_2Object

Returns the value of attribute street_2.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def street_2
  @street_2
end

#zipObject

Returns the value of attribute zip.



3
4
5
# File 'lib/bigcommerce_api/address.rb', line 3

def zip
  @zip
end

Class Method Details

.all(customer_id, params = {}) ⇒ Object



34
35
36
37
# File 'lib/bigcommerce_api/address.rb', line 34

def all(customer_id, params={})
  resources = BigcommerceAPI::Base.get("/customers/#{customer_id}/addresses", query: date_adjust(params))
  (resources.success? and !resources.nil?) ? resources.collect{|r| self.new(r)} : []
end

.find(customer_id, id) ⇒ Object



39
40
41
42
# File 'lib/bigcommerce_api/address.rb', line 39

def find(customer_id, id)
  r = BigcommerceAPI::Base.get("/customers/#{customer_id}/addresses/#{id}")
  (r.success? and !r.nil?) ? self.new(r) : nil
end

Instance Method Details

#find_for_reloadObject

we override this on resources that need paired IDs for find



29
30
31
# File 'lib/bigcommerce_api/address.rb', line 29

def find_for_reload
  self.class.find(self.customer_id, self.id)
end

#parentObject



24
25
26
# File 'lib/bigcommerce_api/address.rb', line 24

def parent
  'customer'
end

#resource_urlObject



20
21
22
# File 'lib/bigcommerce_api/address.rb', line 20

def resource_url
  "customers/#{self.customer_id}/addresses"
end