Class: Nozbe::ActionNewApiCall

Inherits:
ApiCall
  • Object
show all
Defined in:
lib/nozbe/action.rb

Overview

This class is used internaly by the Action class to make the API call that create a new action

Constant Summary

Constants inherited from ApiCall

Nozbe::ApiCall::API_BASE_URL

Instance Attribute Summary

Attributes inherited from ApiCall

#action, #parameters, #required_parameters

Instance Method Summary collapse

Methods inherited from ApiCall

action, #build_query_string, #build_request_path, #call, #do_request, #url_encode

Constructor Details

#initialize(user_key, action) ⇒ ActionNewApiCall

Returns a new instance of ActionNewApiCall.



111
112
113
114
115
116
117
118
119
120
# File 'lib/nozbe/action.rb', line 111

def initialize(user_key, action)
  params = {
    :name => url_encode(action.name), 
    :project_id => action.project.id, 
    :context_id => action.context.id,
    :time => action.time}
  params[:next] = "true" if action.next
  super(user_key, params)
  @action = action
end

Instance Method Details

#parse(json) ⇒ Object

Parse the JSON response, and return the action instance with its ID set



122
123
124
125
126
# File 'lib/nozbe/action.rb', line 122

def parse(json)
  res = super(json)
  @action.id = res["response"]
  @action
end