Class: Nozbe::ActionsListApiCall

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 list all actions

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, #initialize, #url_encode

Constructor Details

This class inherits a constructor from Nozbe::ApiCall

Instance Method Details

#parse(json) ⇒ Object

Parse the JSON response, and return an Array of Action instances, or an empty array if no actions are found.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/nozbe/action.rb', line 69

def parse(json)
  actions = super(json)
  return [] if actions.nil?
  actions.collect do |raw_action|
    action = Action.new
    action.id = raw_action["id"]
    action.name = raw_action["name"]
    action.name_show = raw_action["name_show"]
    action.done = raw_action["done"] == 1
    action.done_time = raw_action["done_time"]
    action.time = raw_action["time"]
    action.next = raw_action["next"] == "next"
    action.project = Nozbe::Project.new
    action.project.id = raw_action["project_id"]
    action.project.name = raw_action["project_name"]
    action.context = Nozbe::Context.new
    action.context.id = raw_action["context_id"]
    action.context.name = raw_action["context_name"]
    action.context.icon = raw_action["context_icon"]
    action
  end
end