Module: Evropochta::Auth::JWT

Extended by:
Services::ApiService
Includes:
Config
Included in:
Services::Shared
Defined in:
lib/evropochta/auth/jwt.rb

Constant Summary

Constants included from Config

Config::SERVICE_NUMBER, Config::USER_LOGIN_NAME, Config::USER_LOGIN_NAME_TYPE_ID, Config::USER_PASSWORD

Class Method Summary collapse

Methods included from Services::ApiService

api_url, do_request, handle_response

Class Method Details

.jwt_post_bodyObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/evropochta/auth/jwt.rb', line 13

def jwt_post_body
  {
    CRC: "",
    Packet: {
      JWT: "null",
      MethodName: "GetJWT",
      ServiceNumber: SERVICE_NUMBER,
      Data: {
        LoginName: USER_LOGIN_NAME,
        Password: USER_PASSWORD,
        LoginNameTypeId: USER_LOGIN_NAME_TYPE_ID
      }
    }
  }
end

.jwt_tokenObject



9
10
11
# File 'lib/evropochta/auth/jwt.rb', line 9

def jwt_token
  @jwt_token ||= handle_response(do_request(post_body: jwt_post_body)).dig(0, "JWT")
end