Class: Asdawqw::AuthorizationController

Inherits:
BaseController show all
Defined in:
lib/asdawqw/controllers/authorization_controller.rb

Overview

AuthorizationController

Class Attribute Summary collapse

Attributes inherited from BaseController

#http_call_back, #http_client

Instance Method Summary collapse

Methods inherited from BaseController

#execute_request, #initialize, #validate_parameters, #validate_response

Constructor Details

This class inherits a constructor from Asdawqw::BaseController

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



12
13
14
# File 'lib/asdawqw/controllers/authorization_controller.rb', line 12

def instance
  @instance
end

Instance Method Details

#get_login(username, password) ⇒ Object

In order to begin utilizing the platform APIs, your application must be authenticated and authorized to access domain resources. Follow the URL with your credentials and obtain an authorization token which is used in every request. You will have 2 types of tokens. One is on the PMS level, and this one should be used when you send requests related to PMS/PM data. For managing properties, you will need a token on PM level, with PM credentials. For every API call it will be noted which API credentials you should use. (for PMS or PM)

Parameters:

  • username (String)

    Required parameter: Your account email address

  • password (String)

    Required parameter: Your password

Returns:

  • Authorization response from the API call



31
32
33
34
35
36
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
# File 'lib/asdawqw/controllers/authorization_controller.rb', line 31

def (username,
              password)
  # Prepare query url.
  _path_url = '/authc/login'
  _query_builder = Configuration.get_base_uri
  _query_builder << _path_url
  _query_builder = APIHelper.append_url_with_query_parameters(
    _query_builder,
    {
      'username' => username,
      'password' => password
    },
    array_serialization: Configuration.array_serialization
  )
  _query_url = APIHelper.clean_url _query_builder
  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'x-api-key' => Configuration.x_api_key
  }
  # Prepare and execute HttpRequest.
  _request = @http_client.get(
    _query_url,
    headers: _headers
  )
  _context = execute_request(_request)
  validate_response(_context)
  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
  Authorization.from_hash(decoded)
end

#instanceObject



15
16
17
# File 'lib/asdawqw/controllers/authorization_controller.rb', line 15

def instance
  self.class.instance
end