Class: Sequence::Action::ClientModule

Inherits:
ClientModule show all
Defined in:
lib/sequence/action.rb

Instance Attribute Summary

Attributes inherited from ClientModule

#client

Instance Method Summary collapse

Methods inherited from ClientModule

#initialize

Constructor Details

This class inherits a constructor from Sequence::ClientModule

Instance Method Details

#list(filter: nil, filter_params: nil) ⇒ Query

Execute a query, returning an enumerable over individual actions.

Examples:

List all actions after a certain time

ledger.actions.list(
  filter: 'timestamp > $1',
  filter_params: ['1985-10-26T01:21:00Z']
).each do |action|
  puts 'timestamp: ' + action.timestamp
  puts 'amount: ' + action.amount
end

Parameters:

  • filter (String) (defaults to: nil)

    A filter expression.

  • filter_params (Array<String|Integer>) (defaults to: nil)

    A list of values that will be interpolated into the filter expression.

Returns:



86
87
88
# File 'lib/sequence/action.rb', line 86

def list(filter: nil, filter_params: nil)
  ListQuery.new(client, filter: filter, filter_params: filter_params)
end

#sum(filter: nil, filter_params: nil, group_by: nil) ⇒ Query

Execute a query, returning an enumerable over sums of actions.

Parameters:

  • filter (String) (defaults to: nil)

    A filter expression.

  • filter_params (Array<String|Integer>) (defaults to: nil)

    A list of values that will be interpolated into the filter expression.

  • group_by (Array<String>) (defaults to: nil)

    A list of fields along which action values will be summed.

Returns:



109
110
111
112
113
114
115
116
# File 'lib/sequence/action.rb', line 109

def sum(filter: nil, filter_params: nil, group_by: nil)
  SumQuery.new(
    client,
    filter: filter,
    filter_params: filter_params,
    group_by: group_by,
  )
end

#update_tags(id:, tags: nil) ⇒ void

This method returns an undefined value.

Update an action’s tags.

Parameters:

  • id (String)

    The ID of the action.

  • tags (Hash) (defaults to: nil)

    A new set of tags, which will replace the existing tags.

Raises:

  • (ArgumentError)


96
97
98
99
# File 'lib/sequence/action.rb', line 96

def update_tags(id:, tags: nil)
  raise ArgumentError, ':id cannot be blank' if id == ''
  client.session.request('update-action-tags', id: id, tags: tags)
end