Class: CloudKit
Instance Attribute Summary collapse
-
#session_token ⇒ Object
writeonly
debug_output $stdout.
Instance Method Summary collapse
-
#initialize(api_token, container, environment = "production", database = "public", version = 1) ⇒ CloudKit
constructor
A new instance of CloudKit.
- #lookup(record_names, user_options = {}) ⇒ Object
- #modify(operations, user_options = {}) ⇒ Object
- #query(record_type, filter_by = nil, sort_by = nil, user_options = {}) ⇒ Object
Constructor Details
#initialize(api_token, container, environment = "production", database = "public", version = 1) ⇒ CloudKit
Returns a new instance of CloudKit.
16 17 18 19 20 21 22 |
# File 'lib/cloud_kit.rb', line 16 def initialize(api_token, container, environment = "production", database = "public", version = 1) @api_token = api_token @container = container @environment = environment @database = database @version = version end |
Instance Attribute Details
#session_token=(value) ⇒ Object (writeonly)
debug_output $stdout
14 15 16 |
# File 'lib/cloud_kit.rb', line 14 def session_token=(value) @session_token = value end |
Instance Method Details
#lookup(record_names, user_options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cloud_kit.rb', line 47 def lookup(record_names, = {}) records = [] record_names.each do |record_name| records << {:recordName => record_name} end = {:body => {:records => records}.to_json, :query => } .merge! self.class.post("#{uri_base}/records/lookup", ) end |
#modify(operations, user_options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cloud_kit.rb', line 24 def modify(operations, = {}) = {:body => {:operations => operations}.to_json, :query => } .merge! response = self.class.post("#{uri_base}/records/modify", ) # Requires authentication if response.code == 421 puts "Authentication required: #{response.parsed_response["redirectURL"]}" end response end |
#query(record_type, filter_by = nil, sort_by = nil, user_options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/cloud_kit.rb', line 37 def query(record_type, filter_by = nil, sort_by = nil, = {}) = {:recordType => record_type} [:filterBy] = filter_by if filter_by [:sortBy] = sort_by if sort_by = {:body => {:query => }.to_json, :query => } .merge! self.class.post("#{uri_base}/records/query", ) end |