Class: Chargify::ProductFamily::Component

Inherits:
Base
  • Object
show all
Defined in:
lib/chargify_api_ares/resources/product_family.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

element_name, #to_xml

Class Method Details

.create_path(prefix_options = {}, query_options = nil) ⇒ Object



14
15
16
17
18
# File 'lib/chargify_api_ares/resources/product_family.rb', line 14

def self.create_path(prefix_options = {}, query_options = nil)
  check_prefix_options(prefix_options)
  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
  "#{prefix(prefix_options)}:component_kind_plural.#{format.extension}#{query_string(query_options)}"
end

Instance Method Details

#component_kindObject



34
35
36
# File 'lib/chargify_api_ares/resources/product_family.rb', line 34

def component_kind
  @attributes['kind']
end

#component_kind_pluralObject



38
39
40
# File 'lib/chargify_api_ares/resources/product_family.rb', line 38

def component_kind_plural
  "#{self.component_kind}s"
end

#createObject

Create uses a different path other than the collection_path. It is expected to POST to /product_families/:product_family_id/:plural_kind.xml



27
28
29
30
31
32
# File 'lib/chargify_api_ares/resources/product_family.rb', line 27

def create
  connection.post(create_path, encode(:root => component_kind, :except => [:kind]), self.class.headers).tap do |response|
    self.id = id_from_response(response)
    load_attributes_from_response(response)
  end
end

#create_path(options = nil) ⇒ Object



20
21
22
23
# File 'lib/chargify_api_ares/resources/product_family.rb', line 20

def create_path(options = nil)
  path = self.class.create_path(options || prefix_options)
  path.gsub(/:component_kind_plural/, component_kind_plural)
end