Class: RestPack::Core::Client::API
- Inherits:
-
Object
- Object
- RestPack::Core::Client::API
- Defined in:
- lib/restpack_core_client/api.rb
Instance Method Summary collapse
- #get_channel(id) ⇒ Object
- #get_domain(host) ⇒ Object
-
#initialize(domain, access_key) ⇒ API
constructor
A new instance of API.
- #root_configurations ⇒ Object
Constructor Details
#initialize(domain, access_key) ⇒ API
Returns a new instance of API.
10 11 12 13 |
# File 'lib/restpack_core_client/api.rb', line 10 def initialize(domain, access_key) @domain = domain @access_key = access_key end |
Instance Method Details
#get_channel(id) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/restpack_core_client/api.rb', line 15 def get_channel(id) begin response = get("/api/v1/channels/#{id}.json?includes=applications,domains,configurations") hydrate_channel(response) rescue RestClient::ResourceNotFound raise RestPack::ResourceNotFound, "count not find channel id [#{id}]" end end |
#get_domain(host) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/restpack_core_client/api.rb', line 24 def get_domain(host) response = get("/api/v1/domains/search.json?host=#{host}") if response[:domains].empty? raise RestPack::ResourceNotFound, "host is not configured: [#{host}]" end response[:domains].first end |
#root_configurations ⇒ Object
32 33 34 35 |
# File 'lib/restpack_core_client/api.rb', line 32 def root_configurations response = get("/api/v1/configurations/root.json") response[:configurations].map { |c| Configuration.new(c) } end |