Class: Usps::Client
- Inherits:
-
Object
- Object
- Usps::Client
- Includes:
- Api::Endpoints, Faraday::Connection, Faraday::Request
- Defined in:
- lib/usps/client.rb
Constant Summary
Constants included from Api::Endpoints
Class Method Summary collapse
Instance Method Summary collapse
- #build_request(action, options) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Api::Endpoints::ZipCodeLookup
Methods included from Api::Endpoints::Verify
Methods included from Api::Endpoints::USPSReturnsLabel
Methods included from Api::Endpoints::TrackV2
Methods included from Api::Endpoints::SundayHolidayAvailability
Methods included from Api::Endpoints::SCAN
Methods included from Api::Endpoints::RateV4
Methods included from Api::Endpoints::PTSTPod
Methods included from Api::Endpoints::PTSRre
Methods included from Api::Endpoints::PTSPod
Methods included from Api::Endpoints::PTSEmail
Methods included from Api::Endpoints::IntlRateV2
Methods included from Api::Endpoints::HFPFacilityInfo
Methods included from Api::Endpoints::EVSICancel
Methods included from Api::Endpoints::EVSGXGGetLabel
Methods included from Api::Endpoints::EVSPriorityMailIntl
Methods included from Api::Endpoints::EVSFirstClassMailIntl
Methods included from Api::Endpoints::EVSExpressMailIntl
Methods included from Api::Endpoints::CityStateLookup
Methods included from Api::Endpoints::CarrierPickupSchedule
Methods included from Faraday::Request
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 |
# File 'lib/usps/client.rb', line 10 def initialize( = {}) Usps::Config::ATTRIBUTES.each do |key| send("#{key}=", .fetch(key, Usps.config.send(key))) end @logger ||= Usps::Config.logger || Usps::Logger.default @token ||= Usps.config.token @user_id ||= Usps.config.user_id end |
Class Method Details
.config ⇒ Object
32 33 34 |
# File 'lib/usps/client.rb', line 32 def config Config end |
Instance Method Details
#build_request(action, options) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/usps/client.rb', line 19 def build_request(action, ) xml = Builder::XmlMarkup.new(indent: 2) # xml.instruct!(:xml, version: '1.0', encoding: 'utf-8') xml.tag!("#{Usps::Api::Endpoints::ACTIONS[action]}Request", USERID: user_id) do send("build_#{action}_request", xml, ) end end |