lib/mirror-api/timeline.rb in mirror-api-0.0.1 vs lib/mirror-api/timeline.rb in mirror-api-0.0.2

- old
+ new

@@ -1,18 +1,40 @@ +require_relative "timeline_request" +require_relative "timeline_item_request" + module Mirror module Api - class Timeline < Mirror::Api::Base + class Timeline - def invoke_url - @invoke_url ||="#{self.host}/mirror/v1/timeline" + def initialize(credentials) + @credentials = if credentials.is_a?(String) + {:token => credentials} + elsif credentials.is_a?(Hash) + credentials + end + + raise "Invalid credentials #{credentials.inspect}" unless @credentials end - def params - @params + def list(params={}) + TimelineRequest.new(params, 200, @credentials).get end - def successful_response? - @response and @response.code == 201 + def create(params) + TimelineRequest.new(params, 201, @credentials).post end + + def get(id, params=nil) + TimelineItemRequest.new(id, params, 200, @credentials).get + end + + def update(id, params) + # This may become patch later + TimelineItemRequest.new(id, params, 200, @credentials).put + end + + def delete(id) + TimelineItemRequest.new(id, nil, 200, @credentials).delete + end end end -end \ No newline at end of file +end