Class: ApiRegistro::Client
- Inherits:
-
Object
- Object
- ApiRegistro::Client
- Includes:
- HTTPSupport
- Defined in:
- lib/api_registro/client.rb
Instance Method Summary collapse
- #create_contact(opts = {}) ⇒ Object
- #find_contact(document_number) ⇒ Object
- #find_domain(domain_name) ⇒ Object
-
#initialize(token, environment) ⇒ Client
constructor
A new instance of Client.
- #register_domain(domain, document_number) ⇒ Object
Methods included from HTTPSupport
Constructor Details
#initialize(token, environment) ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/api_registro/client.rb', line 5 def initialize(token, environment) @token = token @env = environment end |
Instance Method Details
#create_contact(opts = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/api_registro/client.rb', line 10 def create_contact(opts={}) = { headers: { "Accept" => "application/json", "Content-Type" => "application/json", "Authorization" => "Token #{@token}" }, body: opts.to_json } JSON.parse(request(url_for(:create_contact), ApiRegistro::SupportedMethods::POST, )) end |
#find_contact(document_number) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/api_registro/client.rb', line 21 def find_contact(document_number) = { headers: { "Accept" => "application/json", "authorization" => @token } } JSON.parse(request(url_for(:find_contact, document_number), ApiRegistro::SupportedMethods::GET, )) end |
#find_domain(domain_name) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/api_registro/client.rb', line 39 def find_domain(domain_name) = { headers: { "Accept" => "application/json", "authorization" => @token } } JSON.parse(request(url_for(:find_domain, domain_name), ApiRegistro::SupportedMethods::GET, )) end |
#register_domain(domain, document_number) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/api_registro/client.rb', line 28 def register_domain(domain, document_number) = { headers: { "Accept" => "application/json", "Content-Type" => "application/json", "Authorization" => "Token #{@token}" }, body: {document: document_number}.to_json } JSON.parse(request(url_for(:register_domain, domain), ApiRegistro::SupportedMethods::POST, )) end |