Class: OmniSocials::Resources::HashtagSets

Inherits:
Object
  • Object
show all
Defined in:
lib/omnisocials/resources/hashtag_sets.rb

Overview

Hashtag sets resource: saved, reusable hashtag groups applied to posts at create time (via hashtag_set / hashtag_set_id on posts.create).

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ HashtagSets

Returns a new instance of HashtagSets.



8
9
10
# File 'lib/omnisocials/resources/hashtag_sets.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#create(name:, hashtags:) ⇒ Object

POST /hashtag-sets - create a hashtag set.

hashtags is an Array of tags, or a single String of tags. Apply the set on posts.create via hashtag_set (name, case-insensitive) or hashtag_set_id.



27
28
29
30
31
32
# File 'lib/omnisocials/resources/hashtag_sets.rb', line 27

def create(name:, hashtags:)
  @client.request(
    "POST", "/hashtag-sets",
    json: { "name" => name, "hashtags" => hashtags }
  )
end

#delete(hashtag_set_id) ⇒ Object

DELETE /hashtag-sets/id - delete a hashtag set. Returns nil (204).



43
44
45
# File 'lib/omnisocials/resources/hashtag_sets.rb', line 43

def delete(hashtag_set_id)
  @client.request("DELETE", "/hashtag-sets/#{hashtag_set_id}")
end

#get(hashtag_set_id) ⇒ Object

GET /hashtag-sets/id - fetch a single hashtag set.



18
19
20
# File 'lib/omnisocials/resources/hashtag_sets.rb', line 18

def get(hashtag_set_id)
  @client.request("GET", "/hashtag-sets/#{hashtag_set_id}")
end

#listObject

GET /hashtag-sets - list the workspace's saved hashtag sets.



13
14
15
# File 'lib/omnisocials/resources/hashtag_sets.rb', line 13

def list
  @client.request("GET", "/hashtag-sets")
end

#update(hashtag_set_id, name: nil, hashtags: nil) ⇒ Object

PATCH /hashtag-sets/id - rename and/or replace the tags.

hashtags replaces the FULL list.



37
38
39
40
# File 'lib/omnisocials/resources/hashtag_sets.rb', line 37

def update(hashtag_set_id, name: nil, hashtags: nil)
  body = Internal.drop_nil({ "name" => name, "hashtags" => hashtags })
  @client.request("PATCH", "/hashtag-sets/#{hashtag_set_id}", json: body)
end