Module: Webex::Helpers

Defined in:
lib/webex/helpers.rb

Class Method Summary collapse

Class Method Details

.assert_access_token!Object



25
26
27
28
# File 'lib/webex/helpers.rb', line 25

def assert_access_token!
  return unless Events::Config.access_token.nil?
  raise 'Access Token is not present. Please set your access token to use the SDK.'
end

.endpoint_urlObject



7
8
9
10
11
12
13
# File 'lib/webex/helpers.rb', line 7

def endpoint_url
  if live_token?
    'https://public.api.socio.events'
  else
    'https://public.sandbox-api.socio.events'
  end
end

.introspection_queryObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/webex/helpers.rb', line 49

def introspection_query
  return @introspection_query if @introspection_query
  @introspection_query = <<-QUERY
      query IntrospectionQuery {
        __schema {
          queryType { name }
          mutationType { name }
          subscriptionType { name }
          types {
            ...FullType
          }
          directives {
            name
            description
            locations
            args {
              ...InputValue
            }
          }
        }
      }
      fragment FullType on __Type {
        kind
        name
        description
        fields(includeDeprecated: true) {
          name
          description
          args {
            ...InputValue
          }
          type {
            ...TypeRef
          }
          isDeprecated
          deprecationReason
        }
        inputFields {
          ...InputValue
        }
        interfaces {
          ...TypeRef
        }
        enumValues(includeDeprecated: true) {
          name
          description
          isDeprecated
          deprecationReason
        }
        possibleTypes {
          ...TypeRef
        }
      }
      fragment InputValue on __InputValue {
        name
        description
        type { ...TypeRef }
        defaultValue
      }
      fragment TypeRef on __Type {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                    ofType {
                      kind
                      name
                    }
                  }
                }
              }
            }
          }
        }
      }
  QUERY
end

.live_token?Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/webex/helpers.rb', line 15

def live_token?
  assert_access_token!
  /\Ask_live_.+/.match?(Webex::Events::Config.access_token)
end

.ruby_versionObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/webex/helpers.rb', line 30

def ruby_version
  case RUBY_ENGINE
  when 'ruby'
    "ruby-#{RUBY_VERSION}"
  when 'jruby'
    "jruby-#{JRUBY_VERSION}"
  else
    RUBY_DESCRIPTION
  end
end

.sandbox_token?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/webex/helpers.rb', line 20

def sandbox_token?
  assert_access_token!
  !live_token?
end

.user_agentObject



41
42
43
44
45
46
47
# File 'lib/webex/helpers.rb', line 41

def user_agent
  return @user_agent if @user_agent

  os = RbConfig::CONFIG['host_os']
  hostname = Socket.gethostname
  @user_agent = "Webex Ruby SDK(v#{Webex::Events::VERSION}) - OS(#{os}) - hostname(#{hostname}) - Ruby Version(#{ruby_version})"
end