lib/chartmogul/v1/customers.rb in chartmogul_client-0.0.2 vs lib/chartmogul/v1/customers.rb in chartmogul_client-0.0.3
- old
+ new
@@ -15,33 +15,51 @@
#
# See: https://dev.chartmogul.com/docs/create-custom-attributes-for-customer
#
# customer_id - The String/Integer ChartMogul ID of the customer.
# Specified as part of the URL.
- # options - The Hash options used to create a Attribute (default: {}):
- # :type - The String data type of the custom attribute.
- # Can be String, Integer, Timestamp or Boolean.
- # :key - The String key of the custom attribute.
- # Accepts alphanumeric characters and underscores.
- # :value - The value of the custom attribute.
- # Should be of the data type as specified in *type*.
+ # attributes - The Array options used to create a Attributes (default: []).
#
+ # Examples
+ #
+ # client.customers.attributes.create 'foo', [
+ # { type: 'String', key: 'bar', value: 'baz' },
+ # { type: 'Integer', key: 'qux', value: 1 }
+ # ]
+ #
# Returns the instance of Chartmogul::V1::Request.
- def create(customer_id, **options)
- Chartmogul::V1::Request.new "#{BASE_URI}/#{customer_id}/attributes/custom", options.merge(method: :post, userpwd: client.userpwd)
+ def create(customer_id, attributes = [])
+ Chartmogul::V1::Request.new("#{BASE_URI}/#{customer_id}/attributes/custom",
+ body: MultiJson.dump(custom: attributes),
+ headers: { 'Content-Type' => 'application/json' },
+ method: :post,
+ userpwd: client.userpwd,
+ )
end
# Public: Update Custom Attributes of a Customer.
#
# See: https://dev.chartmogul.com/docs/update-custom-attributes-of-customer
#
# customer_id - The String/Integer ChartMogul ID of the customer.
# Specified as part of the URL.
- # options - The Hash options used to refine the Customer attributes (default: {}).
+ # attributes - The Array options used to refine the Customer attributes (default: []).
#
+ # Examples
+ #
+ # client.customers.attributes.update 'foo', [
+ # { type: 'String', key: 'bar', value: 'baz' },
+ # { type: 'Integer', key: 'qux', value: 1 }
+ # ]
+ #
# Returns the instance of Chartmogul::V1::Request.
- def update(customer_id, **options)
- Chartmogul::V1::Request.new "#{BASE_URI}/#{customer_id}/attributes/custom", options.merge(method: :put, userpwd: client.userpwd)
+ def update(customer_id, attributes = [])
+ Chartmogul::V1::Request.new("#{BASE_URI}/#{customer_id}/attributes/custom",
+ body: MultiJson.dump(custom: attributes),
+ headers: { 'Content-Type' => 'application/json' },
+ method: :put,
+ userpwd: client.userpwd,
+ )
end
end
end
end