Class: Verizon::Configuration

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/configuration.rb,
lib/verizon/models/configuration.rb

Overview

List of the field names and values to set.

Constant Summary collapse

ENVIRONMENTS =

All the environments the SDK can run in.

{
  Environment::PRODUCTION => {
    Server::EDGE_DISCOVERY => 'https://5gedge.verizon.com/api/mec/eds',
    Server::THINGSPACE => 'https://thingspace.verizon.com/api',
    Server::OAUTH_SERVER => 'https://thingspace.verizon.com/api/ts/v1',
    Server::M2M => 'https://thingspace.verizon.com/api/m2m',
    Server::DEVICE_LOCATION => 'https://thingspace.verizon.com/api/loc/v1',
    Server::SUBSCRIPTION_SERVER => 'https://thingspace.verizon.com/api/subsc/v1',
    Server::SOFTWARE_MANAGEMENT_V1 => 'https://thingspace.verizon.com/api/fota/v1',
    Server::SOFTWARE_MANAGEMENT_V2 => 'https://thingspace.verizon.com/api/fota/v2',
    Server::SOFTWARE_MANAGEMENT_V3 => 'https://thingspace.verizon.com/api/fota/v3',
    Server::PERFORMANCE => 'https://5gedge.verizon.com/api/mec',
    Server::DEVICE_DIAGNOSTICS => 'https://thingspace.verizon.com/api/diagnostics/v1',
    Server::CLOUD_CONNECTOR => 'https://thingspace.verizon.com/api/cc/v1',
    Server::HYPER_PRECISE_LOCATION => 'https://thingspace.verizon.com/api/hyper-precise/v1',
    Server::SERVICES => 'https://5gedge.verizon.com/api/mec/services',
    Server::QUALITY_OF_SERVICE => 'https://thingspace.verizon.com/api/m2m/v1/devices'
  },
  Environment::MOCK_SERVER_FOR_LIMITED_AVAILABILITY_SEE_QUICK_START => {
    Server::EDGE_DISCOVERY => 'https://mock.thingspace.verizon.com/api/mec/eds',
    Server::THINGSPACE => 'https://mock.thingspace.verizon.com/api',
    Server::OAUTH_SERVER => 'https://mock.thingspace.verizon.com/api/ts/v1',
    Server::M2M => 'https://mock.thingspace.verizon.com/api/m2m',
    Server::DEVICE_LOCATION => 'https://mock.thingspace.verizon.com/api/loc/v1',
    Server::SUBSCRIPTION_SERVER => 'https://mock.thingspace.verizon.com/api/subsc/v1',
    Server::SOFTWARE_MANAGEMENT_V1 => 'https://mock.thingspace.verizon.com/api/fota/v1',
    Server::SOFTWARE_MANAGEMENT_V2 => 'https://mock.thingspace.verizon.com/api/fota/v2',
    Server::SOFTWARE_MANAGEMENT_V3 => 'https://mock.thingspace.verizon.com/api/fota/v3',
    Server::PERFORMANCE => 'https://mock.thingspace.verizon.com/api/mec',
    Server::DEVICE_DIAGNOSTICS => 'https://mock.thingspace.verizon.com/api/diagnostics/v1',
    Server::CLOUD_CONNECTOR => 'https://mock.thingspace.verizon.com/api/cc/v1',
    Server::HYPER_PRECISE_LOCATION => 'https://mock.thingspace.verizon.com/api/hyper-precise/v1',
    Server::SERVICES => 'https://mock.thingspace.verizon.com/api/mec/services',
    Server::QUALITY_OF_SERVICE => 'https://mock.thingspace.verizon.com/api/m2m/v1/devices'
  }
}.freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(frequency = SKIP) ⇒ Configuration

Returns a new instance of Configuration.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/verizon/configuration.rb', line 47

def initialize(
  connection: nil, adapter: :net_http_persistent, timeout: 60,
  max_retries: 0, retry_interval: 1, backoff_factor: 2,
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
  retry_methods: %i[get put], http_callback: nil,
  environment: Environment::PRODUCTION, thingspace_oauth_credentials: nil,
  vz_m2m_token_credentials: nil
)

  super connection: connection, adapter: adapter, timeout: timeout,
        max_retries: max_retries, retry_interval: retry_interval,
        backoff_factor: backoff_factor, retry_statuses: retry_statuses,
        retry_methods: retry_methods, http_callback: http_callback

  # Current API environment
  @environment = String(environment)

  # The object holding OAuth 2 Client Credentials Grant credentials
  @thingspace_oauth_credentials = thingspace_oauth_credentials

  # The object holding Custom Header Signature credentials
  @vz_m2m_token_credentials = vz_m2m_token_credentials

  # The Http Client to use for making requests.
  set_http_client CoreLibrary::FaradayClient.new(self)
end

Class Attribute Details

.environmentsObject (readonly)

Returns the value of attribute environments.



44
45
46
# File 'lib/verizon/configuration.rb', line 44

def environments
  @environments
end

Instance Attribute Details

#environmentObject (readonly)

The attribute readers for properties.



40
41
42
# File 'lib/verizon/configuration.rb', line 40

def environment
  @environment
end

#frequencyString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/verizon/models/configuration.rb', line 14

def frequency
  @frequency
end

#thingspace_oauth_credentialsObject (readonly)

The attribute readers for properties.



40
41
42
# File 'lib/verizon/configuration.rb', line 40

def thingspace_oauth_credentials
  @thingspace_oauth_credentials
end

#vz_m2m_token_credentialsObject (readonly)

The attribute readers for properties.



40
41
42
# File 'lib/verizon/configuration.rb', line 40

def vz_m2m_token_credentials
  @vz_m2m_token_credentials
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



40
41
42
43
44
45
46
47
48
# File 'lib/verizon/models/configuration.rb', line 40

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  frequency = hash.key?('frequency') ? hash['frequency'] : SKIP

  # Create object from extracted values.
  Configuration.new(frequency)
end

.namesObject

A mapping from model property names to API property names.



17
18
19
20
21
# File 'lib/verizon/models/configuration.rb', line 17

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['frequency'] = 'frequency'
  @_hash
end

.nullablesObject

An array for nullable fields



31
32
33
# File 'lib/verizon/models/configuration.rb', line 31

def self.nullables
  []
end

.optionalsObject

An array for optional fields



24
25
26
27
28
# File 'lib/verizon/models/configuration.rb', line 24

def self.optionals
  %w[
    frequency
  ]
end

Instance Method Details

#clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, environment: nil, thingspace_oauth_credentials: nil, vz_m2m_token_credentials: nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/verizon/configuration.rb', line 74

def clone_with(connection: nil, adapter: nil, timeout: nil,
               max_retries: nil, retry_interval: nil, backoff_factor: nil,
               retry_statuses: nil, retry_methods: nil, http_callback: nil,
               environment: nil, thingspace_oauth_credentials: nil,
               vz_m2m_token_credentials: nil)
  connection ||= self.connection
  adapter ||= self.adapter
  timeout ||= self.timeout
  max_retries ||= self.max_retries
  retry_interval ||= self.retry_interval
  backoff_factor ||= self.backoff_factor
  retry_statuses ||= self.retry_statuses
  retry_methods ||= self.retry_methods
  http_callback ||= self.http_callback
  environment ||= self.environment
  thingspace_oauth_credentials ||= self.thingspace_oauth_credentials
  vz_m2m_token_credentials ||= self.vz_m2m_token_credentials

  Configuration.new(
    connection: connection, adapter: adapter, timeout: timeout,
    max_retries: max_retries, retry_interval: retry_interval,
    backoff_factor: backoff_factor, retry_statuses: retry_statuses,
    retry_methods: retry_methods, http_callback: http_callback,
    environment: environment,
    thingspace_oauth_credentials: thingspace_oauth_credentials,
    vz_m2m_token_credentials: vz_m2m_token_credentials
  )
end

#get_base_uri(server = Server::EDGE_DISCOVERY) ⇒ String

Generates the appropriate base URI for the environment and the server. required.

Parameters:

  • server (Configuration::Server) (defaults to: Server::EDGE_DISCOVERY)

    The server enum for which the base URI is

Returns:

  • (String)

    The base URI.



146
147
148
# File 'lib/verizon/configuration.rb', line 146

def get_base_uri(server = Server::EDGE_DISCOVERY)
  ENVIRONMENTS[environment][server].clone
end