Module: DataMapper::DhApi::Adapter
- Includes:
- HTTParty
- Defined in:
- lib/dm-dh_api-adapter.rb
Defined Under Namespace
Classes: APIRequestError
Class Method Summary collapse
- .api_key(api_key) ⇒ Object
- .dnses ⇒ Object
- .domains ⇒ Object
- .request_api(options) ⇒ Object
- .users ⇒ Object
- .users_pw ⇒ Object
Class Method Details
.api_key(api_key) ⇒ Object
11 12 13 |
# File 'lib/dm-dh_api-adapter.rb', line 11 def self.api_key(api_key) @@api_key = api_key end |
.dnses ⇒ Object
18 19 20 21 |
# File 'lib/dm-dh_api-adapter.rb', line 18 def self.dnses = {:query => {:key => @@api_key, :format => 'json', :cmd => 'dns-list_records'}} request_api() end |
.domains ⇒ Object
14 15 16 17 |
# File 'lib/dm-dh_api-adapter.rb', line 14 def self.domains = {:query => {:key => @@api_key, :format => 'json', :cmd => 'domain-list_domains'}} request_api() end |
.request_api(options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dm-dh_api-adapter.rb', line 31 def self.request_api() response = get('/', ) case response['result'] when 'success' response['data'] when 'error' raise APIRequestError, "Error: #{response['data']}" + (response['reason'].blank? ? " " : " - Reason: #{response['reason']}") else raise APIRequestError, "Unknown exception" end end |
.users ⇒ Object
22 23 24 25 |
# File 'lib/dm-dh_api-adapter.rb', line 22 def self.users = {:query => {:key => @@api_key, :format => 'json', :cmd => 'user-list_users_no_pw'}} request_api() end |
.users_pw ⇒ Object
26 27 28 29 |
# File 'lib/dm-dh_api-adapter.rb', line 26 def self.users_pw = {:query => {:key => @@api_key, :format => 'json', :cmd => 'user-list_users'}} request_api() end |