Class: Checkoff::Tags
- Inherits:
-
Object
- Object
- Checkoff::Tags
- Extended by:
- CacheMethod::ClassMethods
- Defined in:
- lib/checkoff/tags.rb,
sig/checkoff.rbs
Overview
Work with tags in Asana
Constant Summary collapse
- MINUTE =
60- HOUR =
T.let(MINUTE * 60, Numeric)
- DAY =
T.let(24 * HOUR, Numeric)
- REALLY_LONG_CACHE_TIME =
T.let(HOUR * 1, Numeric)
- LONG_CACHE_TIME =
T.let(MINUTE * 15, Numeric)
- SHORT_CACHE_TIME =
T.let(MINUTE, Numeric)
Instance Attribute Summary collapse
-
#client ⇒ Asana::Client
readonly
sord warn - Asana::Client wasn't able to be resolved to a constant in this project.
- #projects ⇒ Checkoff::Projects readonly
- #workspaces ⇒ Checkoff::Workspaces readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#build_params(options) ⇒ ::Hash[Symbol, Object]
@param
options. -
#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), clients: Checkoff::Clients.new(config:), client: clients.client, projects: Checkoff::Projects.new(config:, client:), workspaces: Checkoff::Workspaces.new(config:, client:)) ⇒ Object
constructor
sord warn - Asana::Client wasn't able to be resolved to a constant in this project @param
config. -
#parse(response) ⇒ ::Array[::Hash[untyped, untyped]]
sord warn - Asana::HttpClient::Response wasn't able to be resolved to a constant in this project https://github.com/Asana/ruby-asana/blob/master/lib/asana/resource_includes/response_helper.rb#L7.
-
#tag(workspace_name, tag_name) ⇒ Asana::Resources::Tag?
sord warn - Asana::Resources::Tag wasn't able to be resolved to a constant in this project @param
workspace_name. -
#tag_or_raise(workspace_name, tag_name) ⇒ Asana::Resources::Tag
sord warn - Asana::Resources::Tag wasn't able to be resolved to a constant in this project @sg-ignore.
-
#tasks(workspace_name, tag_name, only_uncompleted: true, extra_fields: []) ⇒ Object
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project @param
workspace_name. -
#tasks_by_tag_gid(workspace_name, tag_gid, only_uncompleted: true, extra_fields: []) ⇒ Object
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project @param
workspace_name.
Constructor Details
#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), clients: Checkoff::Clients.new(config:), client: clients.client, projects: Checkoff::Projects.new(config:, client:), workspaces: Checkoff::Workspaces.new(config:, client:)) ⇒ Object
sord warn - Asana::Client wasn't able to be resolved to a constant in this project
@param config
@param clients
@param client
@param projects
@param workspaces
36 37 38 39 40 41 42 43 44 |
# File 'lib/checkoff/tags.rb', line 36 def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), clients: Checkoff::Clients.new(config:), client: clients.client, projects: Checkoff::Projects.new(config:, client:), workspaces: Checkoff::Workspaces.new(config:, client:)) @workspaces = T.let(workspaces, Checkoff::Workspaces) @projects = T.let(projects, Checkoff::Projects) @client = T.let(client, Asana::Client) end |
Instance Attribute Details
#client ⇒ Asana::Client (readonly)
sord warn - Asana::Client wasn't able to be resolved to a constant in this project
110 111 112 |
# File 'lib/checkoff/tags.rb', line 110 def client @client end |
#projects ⇒ Checkoff::Projects (readonly)
108 109 110 |
# File 'lib/checkoff/tags.rb', line 108 def projects @projects end |
#workspaces ⇒ Checkoff::Workspaces (readonly)
106 107 108 |
# File 'lib/checkoff/tags.rb', line 106 def workspaces @workspaces end |
Class Method Details
.run ⇒ void
This method returns an undefined value.
137 138 139 140 141 142 143 144 145 |
# File 'lib/checkoff/tags.rb', line 137 def run # @type [String] workspace_name = ARGV[0] || raise('Please pass workspace name as first argument') # @type [String] tag_name = ARGV[1] || raise('Please pass tag name as second argument') = Checkoff::Tags.new tag = .tag_or_raise(workspace_name, tag_name) puts "Results: #{tag}" end |
Instance Method Details
#build_params(options) ⇒ ::Hash[Symbol, Object]
@param options
115 116 117 118 119 120 |
# File 'lib/checkoff/tags.rb', line 115 def build_params() { limit: [:per_page], completed_since: [:completed_since] }.reject do |_, v| # @sg-ignore v.nil? || Array(v).empty? end end |
#parse(response) ⇒ ::Array[::Hash[untyped, untyped]]
sord warn - Asana::HttpClient::Response wasn't able to be resolved to a constant in this project https://github.com/Asana/ruby-asana/blob/master/lib/asana/resource_includes/response_helper.rb#L7
@param response
127 128 129 130 131 |
# File 'lib/checkoff/tags.rb', line 127 def parse(response) data = response.body.fetch('data') extra = response.body.except('data') [data, extra] end |
#tag(workspace_name, tag_name) ⇒ Asana::Resources::Tag?
sord warn - Asana::Resources::Tag wasn't able to be resolved to a constant in this project
@param workspace_name
@param tag_name
96 97 98 99 100 |
# File 'lib/checkoff/tags.rb', line 96 def tag(workspace_name, tag_name) workspace = workspaces.workspace_or_raise(workspace_name) = client..(workspace_gid: workspace.gid) .find { |tag| tag.name == tag_name } end |
#tag_or_raise(workspace_name, tag_name) ⇒ Asana::Resources::Tag
sord warn - Asana::Resources::Tag wasn't able to be resolved to a constant in this project @sg-ignore
@param workspace_name
@param tag_name
83 84 85 86 87 88 89 |
# File 'lib/checkoff/tags.rb', line 83 def tag_or_raise(workspace_name, tag_name) t = tag(workspace_name, tag_name) raise "Could not find tag #{tag_name} under workspace #{workspace_name}." if t.nil? t end |
#tasks(workspace_name, tag_name, only_uncompleted: true, extra_fields: []) ⇒ Object
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project
@param workspace_name
@param tag_name
@param only_uncompleted
@param extra_fields
52 53 54 55 56 57 58 59 60 |
# File 'lib/checkoff/tags.rb', line 52 def tasks(workspace_name, tag_name, only_uncompleted: true, extra_fields: []) tag = tag_or_raise(workspace_name, tag_name) tag_gid = tag.gid tasks_by_tag_gid(workspace_name, tag_gid, only_uncompleted:, extra_fields:) end |
#tasks_by_tag_gid(workspace_name, tag_gid, only_uncompleted: true, extra_fields: []) ⇒ Object
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project
@param workspace_name
@param tag_gid
@param only_uncompleted
@param extra_fields
68 69 70 71 72 73 74 75 76 |
# File 'lib/checkoff/tags.rb', line 68 def tasks_by_tag_gid(workspace_name, tag_gid, only_uncompleted: true, extra_fields: []) = projects.(extra_fields:, only_uncompleted:) params = build_params() Asana::Resources::Collection.new(parse(client.get("/tags/#{tag_gid}/tasks", params:, options: [:options])), type: Asana::Resources::Task, client:) end |