Sha256: 6e2fe0c3779c6590521a1fb26f1540450e605cc52247befc00097b8ceacce729

Contents?: true

Size: 867 Bytes

Versions: 9

Compression:

Stored size: 867 Bytes

Contents

module Stream
  class CollectionsClient < Client
    def upsert(collection, objects = [])
      data = {
        data: {
          collection => objects
        }
      }
      make_collection_request(:post, {}, data)
    end

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

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

    private

    def make_collection_request(method, params, data)
      endpoint = '/meta/'
      auth_token = Stream::Signer.create_jwt_token('collections', '*', @api_secret, '*', '*')
      make_request(method, endpoint, auth_token, params, data)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
stream-ruby-2.9.3 lib/stream/collections.rb
stream-ruby-2.9.2 lib/stream/collections.rb
stream-ruby-2.9.1 lib/stream/collections.rb
stream-ruby-2.9.0 lib/stream/collections.rb
stream-ruby-2.8.0 lib/stream/collections.rb
stream-ruby-2.7.1 lib/stream/collections.rb
stream-ruby-2.7.0 lib/stream/collections.rb
stream-ruby-2.6.1 lib/stream/collections.rb
stream-ruby-2.6.0 lib/stream/collections.rb