Class: Nzbn::Api::Addresses

Inherits:
Object
  • Object
show all
Defined in:
lib/nzbn/api/addresses.rb

Overview

Addresses API - Manage entity addresses

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Addresses

Returns a new instance of Addresses.



7
8
9
# File 'lib/nzbn/api/addresses.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#create(nzbn:, address:) ⇒ Models::Address

Add an address to an entity

Examples:

client.addresses.create(nzbn: '9429041925676', address: {
  addressType: 'POSTAL',
  address1: '123 Main St',
  address2: 'Wellington',
  postCode: '6011',
  countryCode: 'NZ'
})

Parameters:

  • nzbn (String)

    13-digit NZBN

  • address (Hash)

    Address attributes

Returns:



36
37
38
39
# File 'lib/nzbn/api/addresses.rb', line 36

def create(nzbn:, address:)
  response = @client.post("/entities/#{nzbn}/addresses", address)
  Models::Address.new(response)
end

#delete(nzbn:, address_id:) ⇒ Boolean

Delete an address from an entity

Parameters:

  • nzbn (String)

    13-digit NZBN

  • address_id (String)

    Unique identifier of the address

Returns:

  • (Boolean)

    True if successful



47
48
49
50
# File 'lib/nzbn/api/addresses.rb', line 47

def delete(nzbn:, address_id:)
  @client.delete("/entities/#{nzbn}/addresses", { uniqueIdentifier: address_id })
  true
end

#list(nzbn:) ⇒ Array<Models::Address>

List addresses for an entity

Parameters:

  • nzbn (String)

    13-digit NZBN

Returns:



16
17
18
19
# File 'lib/nzbn/api/addresses.rb', line 16

def list(nzbn:)
  response = @client.get("/entities/#{nzbn}/addresses")
  parse_addresses(response)
end