Class: Checkoff::Events

Inherits:
Object
  • Object
show all
Extended by:
CacheMethod::ClassMethods
Includes:
Logging
Defined in:
lib/checkoff/events.rb,
sig/checkoff.rbs

Overview

Methods related to the Asana events / webhooks APIs

Constant Summary collapse

MINUTE =

Returns:

  • (Object)
60
HOUR =

Returns:

  • (Object)
MINUTE * 60
DAY =

Returns:

  • (Object)
24 * HOUR
REALLY_LONG_CACHE_TIME =

Returns:

  • (Object)
HOUR * 1
LONG_CACHE_TIME =

Returns:

  • (Object)
MINUTE * 15
SHORT_CACHE_TIME =

Returns:

  • (Object)
MINUTE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), workspaces: Checkoff::Workspaces.new(config:), tasks: Checkoff::Tasks.new(config:), sections: Checkoff::Sections.new(config:), projects: Checkoff::Projects.new(config:), clients: Checkoff::Clients.new(config:), client: clients.client, asana_event_filter_class: Checkoff::Internal::AsanaEventFilter, asana_event_enrichment: Checkoff::Internal::AsanaEventEnrichment.new) ⇒ Object

sord warn - Asana::Client wasn't able to be resolved to a constant in this project @param config

@param workspaces

@param tasks

@param sections

@param projects

@param clients

@param client

@param asana_event_filter_class

@param asana_event_enrichment



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/checkoff/events.rb', line 45

def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
               workspaces: Checkoff::Workspaces.new(config:),
               tasks: Checkoff::Tasks.new(config:),
               sections: Checkoff::Sections.new(config:),
               projects: Checkoff::Projects.new(config:),
               clients: Checkoff::Clients.new(config:),
               client: clients.client,
               asana_event_filter_class: Checkoff::Internal::AsanaEventFilter,
               asana_event_enrichment: Checkoff::Internal::AsanaEventEnrichment.new)
  @workspaces = workspaces
  @tasks = tasks
  @sections = sections
  @projects = projects
  @client = client
  @asana_event_filter_class = asana_event_filter_class
  @asana_event_enrichment = asana_event_enrichment
end

Instance Attribute Details

#asana_event_enrichmentCheckoff::Internal::AsanaEventEnrichment (readonly)



118
119
120
# File 'lib/checkoff/events.rb', line 118

def asana_event_enrichment
  @asana_event_enrichment
end

#clientAsana::Client (readonly)

sord warn - Asana::Client wasn't able to be resolved to a constant in this project

Returns:

  • (Asana::Client)


115
116
117
# File 'lib/checkoff/events.rb', line 115

def client
  @client
end

#projectsCheckoff::Projects (readonly)

Returns:



103
104
105
# File 'lib/checkoff/events.rb', line 103

def projects
  @projects
end

#sectionsCheckoff::Sections (readonly)

Returns:



106
107
108
# File 'lib/checkoff/events.rb', line 106

def sections
  @sections
end

#tasksCheckoff::Tasks (readonly)

Returns:



109
110
111
# File 'lib/checkoff/events.rb', line 109

def tasks
  @tasks
end

#workspacesCheckoff::Workspaces (readonly)



112
113
114
# File 'lib/checkoff/events.rb', line 112

def workspaces
  @workspaces
end

Class Method Details

.runvoid

This method returns an undefined value.



124
125
126
127
128
129
130
131
132
# File 'lib/checkoff/events.rb', line 124

def run
  # @type [String]
  # workspace_name = ARGV[0] || raise('Please pass workspace name as first argument')
  # @type [String]
  # event_name = ARGV[1] || raise('Please pass event name as second argument')
  # events = Checkoff::Events.new
  # event = events.event_or_raise(workspace_name, event_name)
  # puts "Results: #{event}"
end

Instance Method Details

#debugvoid

This method returns an undefined value.

@param message

Parameters:

  • message (Object, nil)


652
# File 'sig/checkoff.rbs', line 652

def debug: (?Object? message) -> void

#enrich_event(asana_event) ⇒ ::Hash[untyped, untyped]

Add useful info (like resource task names) into an event for human consumption

@param asana_event

Parameters:

  • asana_event (::Hash[untyped, untyped])

Returns:

  • (::Hash[untyped, untyped])


78
79
80
# File 'lib/checkoff/events.rb', line 78

def enrich_event(asana_event)
  asana_event_enrichment.enrich_event(asana_event)
end

#enrich_filter(filter) ⇒ ::Hash[String, (String | ::Array[String])]

@param filter

Parameters:

  • filter (::Hash[String, (String | ::Array[String])])

Returns:

  • (::Hash[String, (String | ::Array[String])])


85
86
87
# File 'lib/checkoff/events.rb', line 85

def enrich_filter(filter)
  asana_event_enrichment.enrich_filter(filter)
end

#enrich_webhook_subscription!(webhook_subscription) ⇒ void

This method returns an undefined value.

@param webhook_subscription — Hash of the request made to webhook POST endpoint - https://app.asana.com/api/1.0/webhooks https://developers.asana.com/reference/createwebhook

Parameters:

  • webhook_subscription (::Hash[untyped, untyped])


94
95
96
# File 'lib/checkoff/events.rb', line 94

def enrich_webhook_subscription!(webhook_subscription)
  asana_event_enrichment.enrich_webhook_subscription!(webhook_subscription)
end

#errorvoid

This method returns an undefined value.

@param message

Parameters:

  • message (Object, nil)


643
# File 'sig/checkoff.rbs', line 643

def error: (?Object? message) -> void

#filter_asana_events(filters, asana_events) ⇒ ::Array[::Hash[untyped, untyped]]

@param filters — The filters to match against

@param asana_events — The events that Asana sent

@return — The events that should be acted on

Parameters:

  • filters (::Array[::Hash[untyped, untyped]], nil)
  • asana_events (::Array[::Hash[untyped, untyped]])

Returns:

  • (::Array[::Hash[untyped, untyped]])


67
68
69
70
# File 'lib/checkoff/events.rb', line 67

def filter_asana_events(filters, asana_events)
  asana_event_filter = @asana_event_filter_class.new(filters:)
  asana_events.select { |event| asana_event_filter.matches?(event) }
end

#finervoid

This method returns an undefined value.

@param message

Parameters:

  • message (Object, nil)


655
# File 'sig/checkoff.rbs', line 655

def finer: (?Object? message) -> void

#infovoid

This method returns an undefined value.

@param message

Parameters:

  • message (Object, nil)


649
# File 'sig/checkoff.rbs', line 649

def info: (?Object? message) -> void

#log_levelSymbol

@sg-ignore

Returns:

  • (Symbol)


658
# File 'sig/checkoff.rbs', line 658

def log_level: () -> Symbol

#logger::Logger

Returns:

  • (::Logger)


640
# File 'sig/checkoff.rbs', line 640

def logger: () -> ::Logger

#warnvoid

This method returns an undefined value.

@param message

Parameters:

  • message (Object, nil)


646
# File 'sig/checkoff.rbs', line 646

def warn: (?Object? message) -> void