class ActionNetworkRest::Tags
Attributes
tag_id[RW]
Public Class Methods
new(tag_id = nil, client:)
click to toggle source
Without a tag_id
, this class is used for the Tag creation endpoint. With a tag_id
, this class is used to initialise the Taggings
class, like client.tags(123).taggings
Calls superclass method
# File lib/action_network_rest/tags.rb, line 10 def initialize(tag_id = nil, client:) super(client: client, tag_id: tag_id) end
Public Instance Methods
base_path()
click to toggle source
# File lib/action_network_rest/tags.rb, line 18 def base_path 'tags/' end
create(name)
click to toggle source
# File lib/action_network_rest/tags.rb, line 22 def create(name) post_body = { name: name } response = client.post_request base_path, post_body object_from_response(response) end
find_by_name(name)
click to toggle source
# File lib/action_network_rest/tags.rb, line 28 def find_by_name(name) # Action Network API doesn't support currently OData querying for tags # (https://actionnetwork.org/docs/v2#odata) so we need to retrieve a list of # all tags and iterate to find the one we're looking for. page = 1 loop do tags = list(page: page) return nil if tags.empty? found_tag = tags.find { |t| t.name == name } return found_tag unless found_tag.nil? page += 1 end end
taggings()
click to toggle source
# File lib/action_network_rest/tags.rb, line 14 def taggings @_taggings ||= ActionNetworkRest::Taggings.new(client: client, tag_id: tag_id) end
Private Instance Methods
osdi_key()
click to toggle source
# File lib/action_network_rest/tags.rb, line 46 def osdi_key 'osdi:tags' end