Skip to content

Instantly share code, notes, and snippets.

@fleetio
Created October 18, 2011 20:11
Show Gist options
  • Save fleetio/1296565 to your computer and use it in GitHub Desktop.
Save fleetio/1296565 to your computer and use it in GitHub Desktop.
Creating a quantity_based_component through Chargify API
def setup_components
response = HTTParty.post("#{Chargify.site}/product_families/#{[product_family_id]}/quantity_based_components.json",
:body => component_attributes.as_json,
:basic_auth => {:username => Chargify.api_key, :password => 'X'})
response.code.should == 201
end
def component_attributes
{
:quantity_based_component => {
:name => 'Some Component',
:unit_name => 'unit',
:pricing_scheme => 'tiered',
:prices => [
{
:starting_quantity => 1,
:ending_quantity => 10,
:unit_price => 3.9500
},
{
:starting_quantity => 11,
:ending_quantity => 25,
:unit_price => 3.2500
},
{
:starting_quantity => 26,
:ending_quantity => 50,
:unit_price => 2.9500
}
]
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment