Sha256: 1c64198d62d4f8d05d69b41760d29c546c21a8978fb9d409dfa840cdb01fc286
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module Spearly module Cloud class Client def initialize(token) @token = token end def get_sites(params = {}) uri = "#{ENV['SPEARLY_API_URL']}/sites" uri_parsed = Addressable::URI.parse(uri).normalize.to_s client = Faraday.default_connection res = client.get(uri_parsed, params.as_json, 'Accept' => 'application/vnd.spearly.v2+json', 'Authorization' => @token) if res.status == 200 JSON.parse(res.body)['data'] else [] end end def get_site(site_id) uri = "#{ENV['SPEARLY_API_URL']}/sites/#{site_id}" uri_parsed = Addressable::URI.parse(uri).normalize.to_s client = Faraday.default_connection res = client.get(uri_parsed, nil, 'Accept' => 'application/vnd.spearly.v2+json', 'Authorization' => @token) if res.status == 200 JSON.parse(res.body)['data'] else {} end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spearly-sdk-ruby-0.8.0 | lib/spearly/cloud/client.rb |
spearly-sdk-ruby-0.7.0 | lib/spearly/cloud/client.rb |