Class: OpenSRS::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/opensrs/client.rb

Constant Summary collapse

LIVE_URL =
"https://rr-n1-tor.opensrs.net:55443"
TEST_URL =
"https://horizon.opensrs.net:55443"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username:, api_key:, test: false) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
# File 'lib/opensrs/client.rb', line 13

def initialize(username:, api_key:, test: false)
  @username = username
  @api_key = api_key
  @url = test ? TEST_URL : LIVE_URL
end

Instance Attribute Details

#usernameObject (readonly)

Returns the value of attribute username.



11
12
13
# File 'lib/opensrs/client.rb', line 11

def username
  @username
end

Instance Method Details

#call(action:, object:, attributes: {}, extra: {}) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/opensrs/client.rb', line 19

def call(action:, object:, attributes: {}, extra: {})
  xml = build_xml(action, object, attributes, extra)
  response_body = post(xml)
  result = parse_response(response_body)
  check_for_errors!(result)
  result
end