Sha256: f51fefdcdd7ed420c73a6fe7947e8ca341565d1814253ceb6f661ece333e8902
Contents?: true
Size: 946 Bytes
Versions: 1
Compression:
Stored size: 946 Bytes
Contents
require 'json' require 'rest_client' require 'ostruct' require 'buttercms/hash_to_object' require 'buttercms/butter_collection' require 'buttercms/butter_resource' require 'buttercms/author' require 'buttercms/category' require 'buttercms/post' require 'buttercms/feed' # See https://github.com/jruby/jruby/issues/3113 if RUBY_VERSION < '2.0.0' require_relative 'core_ext/ostruct' end module ButterCMS @api_url = 'https://api.buttercms.com/v2' @token = nil def self.api_token=(token) @token = token end def self.token @token end def self.endpoint @api_url end def self.request(path, options = {}) raise ArgumentError.new "Please set your API token" unless token response = RestClient::Request.execute( method: :get, url: endpoint + path, headers: { params: options.merge(auth_token: @token) }, verify_ssl: false ) JSON.parse(response.body) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
buttercms-ruby-1.0.7 | lib/buttercms-ruby.rb |