Sha256: 8d518ed57466ff721694b87796dad24c4fa4e24b0fc1bac47b0b2e46fbcde62f

Contents?: true

Size: 821 Bytes

Versions: 8

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true

# EndShipper objects are fully-qualified Address objects that require all parameters and get verified upon creation.
class EasyPost::EndShipper < EasyPost::Resource
  # Create an EndShipper object.
  def self.create(params = {}, api_key = nil)
    response = EasyPost.make_request(:post, url, api_key, { address: params })
    EasyPost::Util.convert_to_easypost_object(response, api_key)
  end

  # Updates (saves) an EndShipper object. This requires all parameters to be set.
  def save
    if @unsaved_values.length.positive?
      values = {}
      @unsaved_values.each { |k| values[k] = @values[k] }

      wrapped_params = { address: values }

      response = EasyPost.make_request(:put, url, @api_key, wrapped_params)
      refresh_from(response, api_key)
    end
    self
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
easypost-4.12.0 lib/easypost/end_shipper.rb
easypost-4.11.0 lib/easypost/end_shipper.rb
easypost-4.10.0 lib/easypost/end_shipper.rb
easypost-4.9.0 lib/easypost/end_shipper.rb
easypost-4.8.1 lib/easypost/end_shipper.rb
easypost-4.8.0 lib/easypost/end_shipper.rb
easypost-4.7.1 lib/easypost/end_shipper.rb
easypost-4.7.0 lib/easypost/end_shipper.rb