Class: EndiciaLabelServer::Connection Abstract

Inherits:
Object
  • Object
show all
Includes:
Builders, Parsers
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.

Author:

  • Paul Trippett

Since:

  • 0.1.0

Constant Summary collapse

TEST_URL =

Since:

  • 0.1.0

'https://elstestserver.endicia.com'
LIVE_URL =

Since:

  • 0.1.0

'https://labelserver.endicia.com'
ROOT_PATH =

Since:

  • 0.1.0

'/LabelService/EwsLabelService.asmx/'
GET_POSTAGE_LABEL_ENDPOINT =

Since:

  • 0.1.0

'GetPostageLabelXML'
REQUEST_RATE_ENDPOINT =

Since:

  • 0.1.0

'CalculatePostageRateXML'
REQUEST_RATES_ENDPOINT =

Since:

  • 0.1.0

'CalculatePostageRatesXML'
GET_USER_SIGNUP_ENDPOINT =

Since:

  • 0.1.0

'GetUserSignUpXML'
CHANGE_PASS_PHRASE_ENDPOINT =

Since:

  • 0.1.0

'ChangePassPhraseXML'
DEFAULT_PARAMS =

Since:

  • 0.1.0

{
  test_mode: false
}
HEADERS =

Since:

  • 0.1.0

{
  'Content-Type' => 'application/x-www-form-urlencoded'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Connection

Initializes a new EndiciaLabelServer::Connection object

Parameters:

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

    The initialization options

Options Hash (params):

  • :test_mode (Boolean)

    If TEST_URL should be used for requests to the Endicia Label Server URL

Since:

  • 0.1.0



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

#urlString

The base url to use either TEST_URL or LIVE_URL

Returns:

  • (String)

    the current value of url

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



63
64
65
66
# File 'lib/endicia_label_server/connection.rb', line 63

def (builder = nil, &block)
  builder_proxy(builder, GET_USER_SIGNUP_ENDPOINT, UserSignUpBuilder,
                UserSignUpParser, block)
end