Class: Sydecar::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/sydecar/entity.rb

Constant Summary collapse

URL =
'/v1/entities'
CREATE_URL =
"#{URL}/create"

Class Method Summary collapse

Class Method Details

.create(body:) ⇒ Object

Parameters:

  • body (Hash)


9
10
11
# File 'lib/sydecar/entity.rb', line 9

def create(body:)
  Connection.instance.post(CREATE_URL, body)
end

.find(id:) ⇒ Object

Parameters:

  • id (UUID)


14
15
16
# File 'lib/sydecar/entity.rb', line 14

def find(id:)
  Connection.instance.get("#{URL}/#{id}", { reveal_pii: true })
end

.find_all(params: {}, body: {}) ⇒ Object

String

sort: asc / desc

Integer

limit

Integer

offset

String

start_date (format: yyyy-mm-dd)

String

end_date (format: yyyy-mm-dd)

Parameters:

  • params (Hash) (defaults to: {})

    argument expects to have the following keys

  • body: (Hash) (defaults to: {})

    expects to have “ids” key



31
32
33
34
35
# File 'lib/sydecar/entity.rb', line 31

def find_all(params: {}, body: {})
  query = '?'
  query += URI.encode_www_form(params)
  Connection.instance.post("#{URL}#{query}", body)
end

.update(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


20
21
22
# File 'lib/sydecar/entity.rb', line 20

def update(id:, body:)
  Connection.instance.patch("#{URL}/#{id}", body)
end