Class: UspsApi::OauthScopeOauthAuthorizationCode

Inherits:
Object
  • Object
show all
Defined in:
lib/usps_api/models/oauth_scope_oauth_authorization_code.rb

Overview

OAuth 2 scopes supported by the API

Constant Summary collapse

OAUTH_SCOPE_OAUTH_AUTHORIZATION_CODE =
[
  # read-only access to all addresses endpoints
  ADDRESSES = 'addresses'.freeze,

  # Get adjustments for a tracking number.
  ADJUSTMENTS = 'adjustments'.freeze,

  # get mail direction file links
  FAST_APPOINTMENTS = 'fast-appointments'.freeze,

  # read write access to all pickup endpoints
  PICKUP = 'pickup'.freeze,

  # TODO: Write general description for CARRIER_PICKUP
  CARRIER_PICKUP = 'carrier-pickup'.freeze,

  # get prices based on ingredients
  PRICES = 'prices'.freeze,

  # Read, create, and cancel access to Labels.
  INTERNATIONAL_LABELS = 'international-labels'.freeze,

  # get prices based on ingredients
  INTERNATIONAL_PRICES = 'international-prices'.freeze,

  # Read, create, and cancel access to Labels.
  LABELS = 'labels'.freeze,

  # read location resources
  LOCATIONS = 'locations'.freeze,

  # TODO: Write general description for PARCEL_LOCKER
  PARCEL_LOCKER = 'parcel-locker'.freeze,

  # read-only access to all shipments endpoints
  LOGISTICS = 'logistics'.freeze,

  # Read, and write access to resources.
  DISPUTES = 'disputes'.freeze,

  # national-change-of-address
  NCOA_DATA_SERVICES = 'ncoa-data-services'.freeze,

  # Read, create and cancel access to Open and Distribute.
  PMOD = 'pmod'.freeze,

  # Get tracking information and create tracking notifications.
  TRACKING = 'tracking'.freeze,

  # read QR Code resources
  QR_CODE = 'qr-code'.freeze,

  # read reconciliation adjustments resources
  RECONCILIATION_ADJUSTMENTS = 'reconciliation-adjustments'.freeze,

  # Both read and create access to Scan Forms API.
  SCAN_FORMS = 'scan-forms'.freeze,

  # Read access to Service Standards.
  SERVICE_STANDARDS = 'service-standards'.freeze,

  # TODO: Write general description for SERVICE_STANDARDS_FILES
  SERVICE_STANDARDS_FILES = 'service-standards-files'.freeze,

  # Read access to Ship Enrollment.
  SHIP_ENROLLMENT = 'ship-enrollment'.freeze,

  # Read, and write access to resources.
  SUBSCRIPTIONS_ADJUSTMENTS = 'subscriptions-adjustments'.freeze,

  # Read, and write access to resources.
  SUBSCRIPTIONS_DISPUTES = 'subscriptions-disputes'.freeze,

  # Read, and write access to resources.
  SUBSCRIPTIONS_NCOA = 'subscriptions-ncoa'.freeze,

  # Read, and write access to resources.
  SUBSCRIPTIONS_PACKAGE_TRANSACTION_DETAILS = 'subscriptions-package-transaction-details'.freeze,

  # Read, and write access to resources.
  SUBSCRIPTIONS_TRACKING = 'subscriptions-tracking'.freeze,

  # Read, and write access to resources.
  SUBSCRIPTIONS_UNPAID_PACKAGES = 'subscriptions-unpaid-packages'.freeze,

  # OpenID Connnect industry standard scope to utilize this API.
  OPENID = 'openid'.freeze,

  # The OpenID Connect industry standard, United States Postal Service
  # authorized access the user's name and company.
  PROFILE = 'profile'.freeze,

  # The OpenID Connect industry standard, United States Postal Service
  # authorized access the user's address.
  ADDRESS = 'address'.freeze,

  # The OpenID Connect industry standard, United States Postal Service
  # authorized access the user's email address.
  EMAIL = 'email'.freeze,

  # United States Postal Service authorized access to the user's payment
  # methods.
  USPSPAYMENT_METHODS = 'usps:payment_methods'.freeze,

  # United States Postal Service authorized access to the user's contract
  # rates.
  USPSCONTRACT_RATES = 'usps:contract_rates'.freeze,

  # United States Postal Service authorized access to the user's mailer IDs.
  USPSMIDS = 'usps:MIDs'.freeze,

  # TODO: Write general description for OAUTH_2_OIDC
  OAUTH_2_OIDC = 'oauth2-oidc'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = ADDRESSES) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/usps_api/models/oauth_scope_oauth_authorization_code.rb', line 130

def self.from_value(value, default_value = ADDRESSES)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'addresses' then ADDRESSES
  when 'adjustments' then ADJUSTMENTS
  when 'fast_appointments' then FAST_APPOINTMENTS
  when 'pickup' then PICKUP
  when 'carrier_pickup' then CARRIER_PICKUP
  when 'prices' then PRICES
  when 'international_labels' then INTERNATIONAL_LABELS
  when 'international_prices' then INTERNATIONAL_PRICES
  when 'labels' then LABELS
  when 'locations' then LOCATIONS
  when 'parcel_locker' then PARCEL_LOCKER
  when 'logistics' then LOGISTICS
  when 'disputes' then DISPUTES
  when 'ncoa_data_services' then NCOA_DATA_SERVICES
  when 'pmod' then PMOD
  when 'tracking' then TRACKING
  when 'qr_code' then QR_CODE
  when 'reconciliation_adjustments' then RECONCILIATION_ADJUSTMENTS
  when 'scan_forms' then SCAN_FORMS
  when 'service_standards' then SERVICE_STANDARDS
  when 'service_standards_files' then SERVICE_STANDARDS_FILES
  when 'ship_enrollment' then SHIP_ENROLLMENT
  when 'subscriptions_adjustments' then SUBSCRIPTIONS_ADJUSTMENTS
  when 'subscriptions_disputes' then SUBSCRIPTIONS_DISPUTES
  when 'subscriptions_ncoa' then SUBSCRIPTIONS_NCOA
  when 'subscriptions_package_transaction_details' then SUBSCRIPTIONS_PACKAGE_TRANSACTION_DETAILS
  when 'subscriptions_tracking' then SUBSCRIPTIONS_TRACKING
  when 'subscriptions_unpaid_packages' then SUBSCRIPTIONS_UNPAID_PACKAGES
  when 'openid' then OPENID
  when 'profile' then PROFILE
  when 'address' then ADDRESS
  when 'email' then EMAIL
  when 'uspspayment_methods' then USPSPAYMENT_METHODS
  when 'uspscontract_rates' then USPSCONTRACT_RATES
  when 'uspsmids' then USPSMIDS
  when 'oauth_2_oidc' then OAUTH_2_OIDC
  else
    default_value
  end
end

.validate(value) ⇒ Object



124
125
126
127
128
# File 'lib/usps_api/models/oauth_scope_oauth_authorization_code.rb', line 124

def self.validate(value)
  return false if value.nil?

  OAUTH_SCOPE_OAUTH_AUTHORIZATION_CODE.include?(value)
end