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

#api, #params, #path_token

Instance Method Summary collapse

Methods inherited from Base

#authorization, #base_params, #create_token_call, #token

Constructor Details

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

Returns a new instance of UrlJson.

Parameters:

  • url (Hash)

    Query parameters to send

  • json (Hash)

    Body parameters to send as JSON

  • generic_params (Hash)

    Generic parameters for OAuth::Base



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

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

Instance Method Details

#create_tokenObject



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

def create_token
  api.call(
    operation:    'POST',
    subpath:      path_token,
    query:        @query.merge(scope: params[:scope]), # scope is here because it may change over time (node)
    content_type: Rest::MIME_JSON,
    body:         @body,
    headers:      {'Accept' => Rest::MIME_JSON},
    ret:          :resp
  )
end