class Phaxio::Resources::PhaxCode
Provides functionality for viewing and managing PhaxCodes.
Constants
- DEFAULT_PHAX_CODE_PATH
- PHAX_CODES_PATH
Public Class Methods
create(params = {})
click to toggle source
Create a PhaxCode
. @param params [Hash]
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.
@return [Phaxio::Resources::PhaxCode | File] The created PhaxCode
@raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/phaxcodes/create_phax_code
# 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 = {})
click to toggle source
Retrieve a PhaxCode
. @param params [Hash]
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.
@return [Phaxio::Resources::PhaxCode | File] @raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/phaxcodes/retrieve_phax_code
# 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
Private Class Methods
default_phax_code_path()
click to toggle source
# File lib/phaxio/resources/phax_code.rb, line 83 def default_phax_code_path DEFAULT_PHAX_CODE_PATH end
phax_code_endpoint(identifier)
click to toggle source
# File lib/phaxio/resources/phax_code.rb, line 79 def phax_code_endpoint(identifier) "#{phax_codes_endpoint}/#{identifier}" end
phax_codes_endpoint()
click to toggle source
# File lib/phaxio/resources/phax_code.rb, line 71 def phax_codes_endpoint PHAX_CODES_PATH end
phax_codes_endpoint_png()
click to toggle source
# File lib/phaxio/resources/phax_code.rb, line 75 def phax_codes_endpoint_png "#{phax_codes_endpoint}.png" end