Class: Stream::CollectionsClient

Inherits:
Client
  • Object
show all
Defined in:
lib/stream/collections.rb

Instance Attribute Summary

Attributes inherited from Client

#api_key, #api_secret, #app_id, #client_options

Instance Method Summary collapse

Methods inherited from Client

#collections, #feed, #get_default_params, #get_http_client, #initialize, #make_query_params, #make_request, #personalization, #update_activities, #update_activity

Methods included from Activities

#activity_partial_update, #get_activities

Methods included from Batch

#add_to_many, #follow_many, #unfollow_many

Methods included from SignedRequest

included, #make_signed_request

Constructor Details

This class inherits a constructor from Stream::Client

Instance Method Details

#delete(collection, ids = []) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/stream/collections.rb', line 19

def delete(collection, ids = [])
  params = {
    collection_name: collection,
    ids: ids.join(',')
  }
  make_collection_request(:delete, params, {})
end

#get(collection, ids = []) ⇒ Object



12
13
14
15
16
17
# File 'lib/stream/collections.rb', line 12

def get(collection, ids = [])
  params = {
    foreign_ids: ids.map { |id| "#{collection}:#{id}" }.join(',')
  }
  make_collection_request(:get, params, {})
end

#upsert(collection, objects = []) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/stream/collections.rb', line 3

def upsert(collection, objects = [])
  data = {
    data: {
      collection => objects
    }
  }
  make_collection_request(:post, {}, data)
end