lib/parcel_api/label.rb in parcel_api-0.4.1 vs lib/parcel_api/label.rb in parcel_api-1.0.0

- old
+ new

@@ -16,33 +16,33 @@ # @param label_options [Hash] # @return Single or array of label objects def create(label_options) domestic_url = File.join(LABEL_URL, 'domestic') - response = @connection.post domestic_url, label_options - labels = response.body['labels'].map {|label| OpenStruct.new(label)} + response = @connection.post domestic_url, body: label_options.to_json, headers: { 'Content-Type' => 'application/json' } + labels = response.parsed['labels'].map {|label| OpenStruct.new(label)} labels.first if labels.count == 1 end # Create an international label with the specified options # @param label_options [Hash] # @return Single or array of label objects def international_create(label_options) international_url = File.join(LABEL_URL, 'international') - response = @connection.post international_url, label_options - labels = response.body['labels'].map {|label| OpenStruct.new(label)} + response = @connection.post international_url, body: label_options.to_json, headers: { 'Content-Type' => 'application/json' } + labels = response.parsed['labels'].map {|label| OpenStruct.new(label)} labels.first if labels.count == 1 end # Get label details # @param label_id [String] # @return Object of label details def details(label_id) details_url = File.join(LABEL_URL, "#{label_id}.json") response = @connection.get details_url - details = response.body.tap {|d| d.delete('success')} + details = response.parsed.tap {|d| d.delete('success')} OpenStruct.new(details) end # Download label # @param label_id [String]