Module: TridentAssistant::API::Collection
- Included in:
- TridentAssistant::API
- Defined in:
- lib/trident_assistant/api/collection.rb
Overview
api for collection
Instance Method Summary collapse
- #collection(id) ⇒ Object
- #collections(**kwargs) ⇒ Object
- #create_collection(**kwargs) ⇒ Object
- #update_collection(id, **kwargs) ⇒ Object
Instance Method Details
#collection(id) ⇒ Object
7 8 9 10 11 |
# File 'lib/trident_assistant/api/collection.rb', line 7 def collection(id) client.get( "api/collections/#{id}" ) end |
#collections(**kwargs) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/trident_assistant/api/collection.rb', line 13 def collections(**kwargs) client.get( "api/collections", { page: kwargs[:page] }, { Authorization: "Bearer #{mixin_bot.access_token("GET", "/me", "")}" } ) end |
#create_collection(**kwargs) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/trident_assistant/api/collection.rb', line 25 def create_collection(**kwargs) kwargs = kwargs.with_indifferent_access client .post( "api/collections", { name: kwargs[:name], symbol: kwargs[:symbol], description: kwargs[:description], external_url: kwargs[:external_url], split: kwargs[:split].to_f.round(4), icon_base64: kwargs[:icon_base64], icon_url: kwargs[:icon_url] }, { Authorization: "Bearer #{mixin_bot.access_token("GET", "/me", "")}" } ) end |
#update_collection(id, **kwargs) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/trident_assistant/api/collection.rb', line 45 def update_collection(id, **kwargs) kwargs = kwargs.with_indifferent_access client .put( "api/collections/#{id}", { description: kwargs[:description], external_url: kwargs[:external_url], icon_base64: kwargs[:icon_base64], icon_url: kwargs[:icon_url] }.compact, { Authorization: "Bearer #{mixin_bot.access_token("GET", "/me", "")}" } ) end |