Class: Phaxio::Resources::PhaxCode

Inherits:
Phaxio::Resource show all
Defined in:
lib/phaxio/resources/phax_code.rb

Overview

Provides functionality for viewing and managing PhaxCodes.

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Phaxio::Resource

response_collection, response_record

Instance Attribute Details

#created_atTime

Returns The time that the PhaxCode was created.

Returns:

  • (Time)

    The time that the PhaxCode was created.



20
# File 'lib/phaxio/resources/phax_code.rb', line 20

has_time_attributes %w[created_at]

#identifierString

Returns The identifier for the PhaxCode.

Returns:

  • (String)

    The identifier for the PhaxCode.



# File 'lib/phaxio/resources/phax_code.rb', line 9

#metadataString

Returns The metadata associated with the PhaxCode.

Returns:

  • (String)

    The metadata associated with the PhaxCode.



15
# File 'lib/phaxio/resources/phax_code.rb', line 15

has_normal_attributes %w[identifier metadata]

Class Method Details

.create(params = {}) ⇒ Phaxio::Resources::PhaxCode | File

Create a PhaxCode.

Parameters:

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio.

    • metadata [String] - Metadata to be associated with the PhaxCode.

    • type [String] - If set to “png”, this method will return a PNG file instead of a PhaxCode object.

Returns:

Raises:

See Also:



32
33
34
35
36
37
38
39
40
# File 'lib/phaxio/resources/phax_code.rb', line 32

def create params = {}
  endpoint = case (params[:type] || params['type']).to_s
    when 'png' then phax_codes_endpoint_png
    else phax_codes_endpoint
  end
  result = Client.request :post, endpoint, params
  return result if result.is_a? File
  response_record result
end

.get(params = {}) ⇒ Phaxio::Resources::PhaxCode | File Also known as: find, retrieve

Retrieve a PhaxCode.

Parameters:

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio.

    • identifier [String] - The identifier for the PhaxCode you want to get. If blank, the default PhaxCode will be returned.

    • type [String] - If set to “png”, this method will return a PNG file instead of a PhaxCode object.

Returns:

Raises:

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/phaxio/resources/phax_code.rb', line 52

def get params = {}
  identifier = params[:identifier] || params['identifier']
  endpoint = case (identifier)
    when nil then default_phax_code_path
    else phax_code_endpoint(identifier)
  end
  endpoint = case (params[:type] || params['type']).to_s
    when 'png' then "#{endpoint}.png"
    else endpoint
  end
  result = Client.request :get, endpoint, {}
  return result if result.is_a? File
  response_record result
end