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


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

has_time_attributes %w[created_at]

#identifierString


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


#metadataString


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.


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.


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