Module: Shippo::API::Operations::Create
- Defined in:
- lib/shippo/api/operations/create.rb
Instance Method Summary collapse
-
#create(params = {}) ⇒ Object
Creates an item in the database.
- #debug_log!(api_params, response, instance) ⇒ Object
Instance Method Details
#create(params = {}) ⇒ Object
Creates an item in the database
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/shippo/api/operations/create.rb', line 8 def create(params={}) api_params = params.dup Hashie::Extensions::StringifyKeys.stringify_keys!(api_params) api_params.dup.each { |k, v| api_params[k] = v.id if v.is_a?(::Shippo::API::Resource) && v.id } response = Shippo::API.post("#{url}/", api_params) instance = self.from(response) debug_log!(api_params, response, instance) if Shippo::API.debug? instance end |
#debug_log!(api_params, response, instance) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/shippo/api/operations/create.rb', line 21 def debug_log!(api_params, response, instance) puts "#{self.name}->create / request : \n" ap(api_params) puts "#{self.name}->create / response: \n" ap(response) puts "#{self.name}->create / from: \n" ap(instance) end |