Class: PhoneComClient::OauthApi

Inherits:
Object
  • Object
show all
Defined in:
lib/phone_com_client/api/oauth_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ OauthApi

Returns a new instance of OauthApi.



19
20
21
# File 'lib/phone_com_client/api/oauth_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/phone_com_client/api/oauth_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_oauth_access_token(opts = {}) ⇒ OauthAccessToken

To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. For Authorization Code Grant, the input parameter ‘code’ is generated via the Create Authorization API. NOTE: The Create Access Token API now accepts requests in query string format as well as JSON body format. See OAuth for more details on how to obtain client id and client secret to create an access token at real time.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



27
28
29
30
# File 'lib/phone_com_client/api/oauth_api.rb', line 27

def create_oauth_access_token(opts = {})
  data, _status_code, _headers = create_oauth_access_token_with_http_info(opts)
  data
end

#create_oauth_access_token_with_http_info(opts = {}) ⇒ Array<(OauthAccessToken, Fixnum, Hash)>

To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. For Authorization Code Grant, the input parameter &#39;code&#39; is generated via the Create Authorization API. NOTE: The Create Access Token API now accepts requests in query string format as well as JSON body format. See OAuth for more details on how to obtain client id and client secret to create an access token at real time.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(OauthAccessToken, Fixnum, Hash)>)

    OauthAccessToken data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
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
# File 'lib/phone_com_client/api/oauth_api.rb', line 37

def create_oauth_access_token_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OauthApi.create_oauth_access_token ...'
  end
  # resource path
  local_var_path = '/oauth/access-token'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(opts[:'data'])
  auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'OauthAccessToken')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OauthApi#create_oauth_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_oauth_authorization(client_id, response_type, scope, redirect_uri, opts = {}) ⇒ nil

Create Authorization Code or Access Token. Create Authorization Code or Access Token. The /oauth/authorization API supports Authorization Grant and Implicit Grant. In Authorization Grant, this API returns a code (response_type=code) for clients implemented in a browser using a scripting language such as JavaScript. Users may then use the code via the Create Access Token API to create an access token. The Implicit Grant is a simplified authorization code flow. In the implicit flow, instead of issuing the client an authorization code, the client is issued an access token (response_type=token) directly. See OAuth for more details on how to obtain client id and client secret to create authorization code access token at real time.

Parameters:

  • client_id

    Client ID

  • response_type

    &#39;token&#39; for Implicit Grant; &#39;code&#39; for Authorization Code Grant

  • scope

    account-owner, extension-user and/or methods:ALL, separated by space (%20)

  • redirect_uri

    The URL where the response data of this API is redirected to

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


80
81
82
83
# File 'lib/phone_com_client/api/oauth_api.rb', line 80

def create_oauth_authorization(client_id, response_type, scope, redirect_uri, opts = {})
  create_oauth_authorization_with_http_info(client_id, response_type, scope, redirect_uri, opts)
  nil
end

#create_oauth_authorization_with_http_info(client_id, response_type, scope, redirect_uri, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Create Authorization Code or Access Token. Create Authorization Code or Access Token. The /oauth/authorization API supports Authorization Grant and Implicit Grant. In Authorization Grant, this API returns a code (response_type&#x3D;code) for clients implemented in a browser using a scripting language such as JavaScript. Users may then use the code via the Create Access Token API to create an access token. The Implicit Grant is a simplified authorization code flow. In the implicit flow, instead of issuing the client an authorization code, the client is issued an access token (response_type&#x3D;token) directly. See OAuth for more details on how to obtain client id and client secret to create authorization code access token at real time.

Parameters:

  • client_id

    Client ID

  • response_type

    &#39;token&#39; for Implicit Grant; &#39;code&#39; for Authorization Code Grant

  • scope

    account-owner, extension-user and/or methods:ALL, separated by space (%20)

  • redirect_uri

    The URL where the response data of this API is redirected to

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Fixnum, Hash)>)

    nil, response status code and response headers



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
142
143
144
145
146
# File 'lib/phone_com_client/api/oauth_api.rb', line 93

def create_oauth_authorization_with_http_info(client_id, response_type, scope, redirect_uri, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OauthApi.create_oauth_authorization ...'
  end
  # verify the required parameter 'client_id' is set
  if @api_client.config.client_side_validation && client_id.nil?
    fail ArgumentError, "Missing the required parameter 'client_id' when calling OauthApi.create_oauth_authorization"
  end
  # verify the required parameter 'response_type' is set
  if @api_client.config.client_side_validation && response_type.nil?
    fail ArgumentError, "Missing the required parameter 'response_type' when calling OauthApi.create_oauth_authorization"
  end
  # verify the required parameter 'scope' is set
  if @api_client.config.client_side_validation && scope.nil?
    fail ArgumentError, "Missing the required parameter 'scope' when calling OauthApi.create_oauth_authorization"
  end
  # verify the required parameter 'redirect_uri' is set
  if @api_client.config.client_side_validation && redirect_uri.nil?
    fail ArgumentError, "Missing the required parameter 'redirect_uri' when calling OauthApi.create_oauth_authorization"
  end
  # resource path
  local_var_path = '/oauth/authorization'

  # query parameters
  query_params = {}
  query_params[:'client_id'] = client_id
  query_params[:'response_type'] = response_type
  query_params[:'scope'] = scope
  query_params[:'redirect_uri'] = redirect_uri

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OauthApi#create_oauth_authorization\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_oauth_access_token(opts = {}) ⇒ GetOauthAccessToken

Retrieve details of an access token, such as scope, expiration and extension ID. Retrieve details of an access token, such as scope, expiration and extension ID. Voip ID will be returned as well if scope contains account-owner scope.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



151
152
153
154
# File 'lib/phone_com_client/api/oauth_api.rb', line 151

def get_oauth_access_token(opts = {})
  data, _status_code, _headers = get_oauth_access_token_with_http_info(opts)
  data
end

#get_oauth_access_token_with_http_info(opts = {}) ⇒ Array<(GetOauthAccessToken, Fixnum, Hash)>

Retrieve details of an access token, such as scope, expiration and extension ID. Retrieve details of an access token, such as scope, expiration and extension ID. Voip ID will be returned as well if scope contains account-owner scope.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GetOauthAccessToken, Fixnum, Hash)>)

    GetOauthAccessToken data, response status code and response headers



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
# File 'lib/phone_com_client/api/oauth_api.rb', line 160

def get_oauth_access_token_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OauthApi.get_oauth_access_token ...'
  end
  # resource path
  local_var_path = '/oauth/access-token'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetOauthAccessToken')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OauthApi#get_oauth_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end