Class: EndiciaLabelServer::Connection Abstract
- Inherits:
-
Object
- Object
- EndiciaLabelServer::Connection
- Defined in:
- lib/endicia_label_server/connection.rb
Overview
This class is abstract.
The Connection class acts as the main entry point to performing rate and ship operations against the Endicia API.
Constant Summary collapse
- TEST_URL =
'https://elstestserver.endicia.com'
- LIVE_URL =
'https://labelserver.endicia.com'
- ROOT_PATH =
'/LabelService/EwsLabelService.asmx/'
- GET_POSTAGE_LABEL_ENDPOINT =
'GetPostageLabelXML'
- REQUEST_RATE_ENDPOINT =
'CalculatePostageRateXML'
- REQUEST_RATES_ENDPOINT =
'CalculatePostageRatesXML'
- GET_USER_SIGNUP_ENDPOINT =
'GetUserSignUpXML'
- CHANGE_PASS_PHRASE_ENDPOINT =
'ChangePassPhraseXML'
- DEFAULT_PARAMS =
{ test_mode: false }
- HEADERS =
{ 'Content-Type' => 'application/x-www-form-urlencoded' }
Instance Attribute Summary collapse
-
#url ⇒ String
The base url to use either TEST_URL or LIVE_URL.
Instance Method Summary collapse
- #change_pass_phrase(builder = nil, &block) ⇒ Object
- #get_label(builder = nil, &block) ⇒ Object
-
#initialize(params = {}) ⇒ Connection
constructor
Initializes a new Connection object.
- #rate(builder = nil, &block) ⇒ Object
- #rates(builder = nil, &block) ⇒ Object
- #sign_up(builder = nil, &block) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Connection
Initializes a new EndiciaLabelServer::Connection object
43 44 45 46 |
# File 'lib/endicia_label_server/connection.rb', line 43 def initialize(params = {}) params = DEFAULT_PARAMS.merge(params) self.url = (params[:test_mode]) ? TEST_URL : LIVE_URL end |
Instance Attribute Details
#url ⇒ String
The base url to use either TEST_URL or LIVE_URL
14 15 16 |
# File 'lib/endicia_label_server/connection.rb', line 14 def url @url end |
Instance Method Details
#change_pass_phrase(builder = nil, &block) ⇒ Object
68 69 70 71 |
# File 'lib/endicia_label_server/connection.rb', line 68 def change_pass_phrase(builder = nil, &block) builder_proxy(builder, CHANGE_PASS_PHRASE_ENDPOINT, ChangePassPhraseBuilder, ChangePassPhraseParser, block) end |
#get_label(builder = nil, &block) ⇒ Object
58 59 60 61 |
# File 'lib/endicia_label_server/connection.rb', line 58 def get_label(builder = nil, &block) builder_proxy(builder, GET_POSTAGE_LABEL_ENDPOINT, PostageLabelBuilder, PostageLabelParser, block) end |
#rate(builder = nil, &block) ⇒ Object
48 49 50 51 |
# File 'lib/endicia_label_server/connection.rb', line 48 def rate(builder = nil, &block) builder_proxy(builder, REQUEST_RATE_ENDPOINT, PostageRateBuilder, PostageRateParser, block) end |
#rates(builder = nil, &block) ⇒ Object
53 54 55 56 |
# File 'lib/endicia_label_server/connection.rb', line 53 def rates(builder = nil, &block) builder_proxy(builder, REQUEST_RATES_ENDPOINT, PostageRatesBuilder, PostageRatesParser, block) end |
#sign_up(builder = nil, &block) ⇒ Object
63 64 65 66 |
# File 'lib/endicia_label_server/connection.rb', line 63 def sign_up(builder = nil, &block) builder_proxy(builder, GET_USER_SIGNUP_ENDPOINT, UserSignUpBuilder, UserSignUpParser, block) end |