Module: OpConnect::Client::Items

Included in:
OpConnect::Client
Defined in:
lib/op_connect/client/items.rb

Instance Method Summary collapse

Instance Method Details

#create_item(vault_id:, **attributes) ⇒ Object



28
29
30
# File 'lib/op_connect/client/items.rb', line 28

def create_item(vault_id:, **attributes)
  Item.new post("vaults/#{vault_id}/items", body: attributes).body
end

#delete_item(vault_id:, id:) ⇒ Object



36
37
38
39
40
41
# File 'lib/op_connect/client/items.rb', line 36

def delete_item(vault_id:, id:)
  return true if delete("vaults/#{vault_id}/items/#{id}").status == 204
  false
rescue OpConnect::Error
  false
end

#get_item(vault_id:, id:) ⇒ Object Also known as: item



23
24
25
# File 'lib/op_connect/client/items.rb', line 23

def get_item(vault_id:, id:)
  Item.new get("vaults/#{vault_id}/items/#{id}").body
end

#list_items(vault_id:, **params) ⇒ <Type> Also known as: items

Get a list of items from a vault.

Examples:

client.items(vault_id: vault.id, filter: 'title eq "foo"')

Parameters:

  • vault_id (String)

    The vault UUID.

  • params (Hash)

    Query parameters.

Options Hash (**params):

  • :filter (String)

    Optionally filter the item collection based on item title using SCIM-sytle filters.

Returns:

  • (<Type>)

    <description>

See Also:



18
19
20
# File 'lib/op_connect/client/items.rb', line 18

def list_items(vault_id:, **params)
  get("vaults/#{vault_id}/items", params: params).body.map { |item| Item.new(item) }
end

#replace_item(vault_id:, id:, **attributes) ⇒ Object



32
33
34
# File 'lib/op_connect/client/items.rb', line 32

def replace_item(vault_id:, id:, **attributes)
  Item.new put("vaults/#{vault_id}/items/#{id}", body: attributes).body
end

#update_item(vault_id:, id:, **attributes) ⇒ Object



43
44
45
# File 'lib/op_connect/client/items.rb', line 43

def update_item(vault_id:, id:, **attributes)
  Item.new patch("vaults/#{vault_id}/items/#{id}", body: attributes, headers: {"Content-Type": "applicatoin/json-patch+json"}).body
end