Class: TerminalShop::Resources::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/terminal_shop/resources/address.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Address

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Address.

Parameters:



103
104
105
# File 'lib/terminal_shop/resources/address.rb', line 103

def initialize(client:)
  @client = client
end

Instance Method Details

#create(city: , country: , name: , street1: , zip: , phone: nil, province: nil, street2: nil, request_options: {}) ⇒ TerminalShop::Models::AddressCreateResponse

Create and add a shipping address to the current user.

Parameters:

  • city (String)

    City of the address.

  • country (String)

    ISO 3166-1 alpha-2 country code of the address.

  • name (String)

    The recipient’s name.

  • street1 (String)

    Street of the address.

  • zip (String)

    Zip code of the address.

  • phone (String)

    Phone number of the recipient.

  • province (String)

    Province or state of the address.

  • street2 (String)

    Apartment, suite, etc. of the address.

  • request_options (TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
# File 'lib/terminal_shop/resources/address.rb', line 31

def create(params)
  parsed, options = TerminalShop::AddressCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "address",
    body: parsed,
    model: TerminalShop::Models::AddressCreateResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ TerminalShop::Models::AddressDeleteResponse

Delete a shipping address from the current user.

Parameters:

Returns:

See Also:



71
72
73
74
75
76
77
78
# File 'lib/terminal_shop/resources/address.rb', line 71

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["address/%1$s", id],
    model: TerminalShop::Models::AddressDeleteResponse,
    options: params[:request_options]
  )
end

#get(id, request_options: {}) ⇒ TerminalShop::Models::AddressGetResponse

Get the shipping address with the given ID.

Parameters:

Returns:

See Also:



91
92
93
94
95
96
97
98
# File 'lib/terminal_shop/resources/address.rb', line 91

def get(id, params = {})
  @client.request(
    method: :get,
    path: ["address/%1$s", id],
    model: TerminalShop::Models::AddressGetResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ TerminalShop::Models::AddressListResponse

Get the shipping addresses associated with the current user.

Parameters:

Returns:

See Also:



51
52
53
54
55
56
57
58
# File 'lib/terminal_shop/resources/address.rb', line 51

def list(params = {})
  @client.request(
    method: :get,
    path: "address",
    model: TerminalShop::Models::AddressListResponse,
    options: params[:request_options]
  )
end