Class: UspsApi::OauthScopeOauthClientCredentials

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

Overview

OAuth 2 scopes supported by the API

Constant Summary collapse

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

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

  # check for available slots and create appointments
  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,

  # Both read and create access to containers API.
  CONTAINERS = 'containers'.freeze,

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

  # read/write access to all campaigns endpoints
  CAMPAIGNS = 'campaigns'.freeze,

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

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

  # Read access to Service Standard.
  INTERNATIONAL_SERVICE_STANDARD = 'international-service-standard'.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,

  # 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,

  # Both read and write access to the payments API.
  PAYMENTS = 'payments'.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,

  # get service standards directory
  SERVICE_STANDARDS_DIRECTORY = 'service-standards-directory'.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 access to Shipping Options API.
  SHIPMENTS = 'shipments'.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



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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/usps_api/models/oauth_scope_oauth_client_credentials.rb', line 148

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 'containers' then CONTAINERS
  when 'prices' then PRICES
  when 'campaigns' then CAMPAIGNS
  when 'international_labels' then INTERNATIONAL_LABELS
  when 'international_prices' then INTERNATIONAL_PRICES
  when 'international_service_standard' then INTERNATIONAL_SERVICE_STANDARD
  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 'payments' then PAYMENTS
  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_directory' then SERVICE_STANDARDS_DIRECTORY
  when 'service_standards_files' then SERVICE_STANDARDS_FILES
  when 'ship_enrollment' then SHIP_ENROLLMENT
  when 'shipments' then SHIPMENTS
  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



142
143
144
145
146
# File 'lib/usps_api/models/oauth_scope_oauth_client_credentials.rb', line 142

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

  OAUTH_SCOPE_OAUTH_CLIENT_CREDENTIALS.include?(value)
end