class Checkoff::CustomFields
Work with custom fields in Asana
Constants
- DAY
- HOUR
- LONG_CACHE_TIME
- MINUTE
- REALLY_LONG_CACHE_TIME
- SHORT_CACHE_TIME
Attributes
client[R]
workspaces[R]
Public Class Methods
new(config: Checkoff::ConfigLoader.load(:asana), workspaces: Checkoff::Workspaces.new(config: config), clients: Checkoff::Clients.new(config: config), client: clients.client)
click to toggle source
# File lib/checkoff/custom_fields.rb, line 23 def initialize(config: Checkoff::ConfigLoader.load(:asana), workspaces: Checkoff::Workspaces.new(config: config), clients: Checkoff::Clients.new(config: config), client: clients.client) @workspaces = workspaces @client = client end
Private Class Methods
run()
click to toggle source
# File lib/checkoff/custom_fields.rb, line 53 def run workspace_name = ARGV[0] || raise('Please pass workspace name as first argument') custom_field_name = ARGV[1] || raise('Please pass custom_field name as second argument') custom_fields = Checkoff::CustomFields.new custom_field = custom_fields.custom_field_or_raise(workspace_name, custom_field_name) puts "Results: #{custom_field}" end
Public Instance Methods
custom_field(workspace_name, custom_field_name)
click to toggle source
# File lib/checkoff/custom_fields.rb, line 39 def custom_field(workspace_name, custom_field_name) workspace = workspaces.workspace_or_raise(workspace_name) custom_fields = client.custom_fields.get_custom_fields_for_workspace(workspace_gid: workspace.gid) custom_fields.find { |custom_field| custom_field.name == custom_field_name } end
custom_field_or_raise(workspace_name, custom_field_name)
click to toggle source
# File lib/checkoff/custom_fields.rb, line 31 def custom_field_or_raise(workspace_name, custom_field_name) custom_field = custom_field(workspace_name, custom_field_name) raise "Could not find custom_field #{custom_field_name} under workspace #{workspace_name}." if custom_field.nil? custom_field end