Module: Evropochta::Services::Shared

Extended by:
Auth::JWT, ApiService
Includes:
Config
Defined in:
lib/evropochta/services/shared.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 ApiService

api_url, do_request, handle_response

Methods included from Auth::JWT

jwt_post_body, jwt_token

Class Method Details

.post_body(opts) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/evropochta/services/shared.rb', line 21

def post_body(opts)
  {
    CRC: "",
    Packet: {
      JWT: opts[:token],
      MethodName: opts[:method_name],
      ServiceNumber: SERVICE_NUMBER,
      Data: opts[:data]
    }
  }
end

.request(method_name, data = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/evropochta/services/shared.rb', line 10

def request(method_name, data={})
  token = jwt_token
  request_options = {
    token: token,
    data: data,
    method_name: method_name
  }

  handle_response(do_request(post_body: post_body(request_options)))
end