Class: Aspera::OAuth::UrlJson

Inherits:
Base
  • Object
show all
Defined in:
lib/aspera/oauth/url_json.rb

Overview

This class is used to create a token using a JSON body and a URL

Instance Attribute Summary

Attributes inherited from Base

#scope

Instance Method Summary collapse

Methods inherited from Base

#create_token_call, #optional_scope_client_id, #token

Constructor Details

#initialize(url:, json:, **generic_params) ⇒ UrlJson

Returns a new instance of UrlJson.

Parameters:

  • url

    URL to send the JSON body

  • json

    JSON body to send



11
12
13
14
15
16
17
18
19
20
# File 'lib/aspera/oauth/url_json.rb', line 11

def initialize(
  url:,
  json:,
  **generic_params
)
  super(**generic_params)
  @body = json
  @query = url
  @identifiers.push(@body[:url_token])
end

Instance Method Details

#create_tokenObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/aspera/oauth/url_json.rb', line 22

def create_token
  @api.call(
    operation:   'POST',
    subpath:     @path_token,
    headers:     {'Accept' => 'application/json'},
    query:       @query.merge(scope: @scope), # scope is here because it may change over time (node)
    body:        @body,
    body_type:   :json
  )
end