~vesto/huginn_venmo_agent

2ace51965d15d8110094cb925d9fef1fa3d321e7 — Steve Gattuso 3 years ago f11a7a8
update library
2 files changed, 65 insertions(+), 5 deletions(-)

R lib/huginn_venmo_agent/{venmo_agent.rb => create_venmo_transaction_agent.rb}
R lib/huginn_venmo_agent/{venmo_timeline_agent.rb => read_venmo_timeline_agent.rb}
R lib/huginn_venmo_agent/venmo_agent.rb => lib/huginn_venmo_agent/create_venmo_transaction_agent.rb +30 -2
@@ 1,11 1,39 @@
module Agents
  class VenmoAgent < Agent
  class CreateVenmoTransactionAgent < Agent
    API_BASE = 'https://api.venmo.com/v1'

    include FormConfigurable

    can_dry_run!

    description <<-MD
      This agent connects your Huginn instance to the
      [unofficial Venmo API](https://github.com/mmohades/VenmoApiDocumentation),
      allowing you to create Venmo transactions by sending it properly
      formatted events. Generally you'll want to use this in combination with a
      Javascript agent, which will allow you to intake arbitrary events and
      properly transform them into the event schema expected by this agent.

      Note that this agent requires you to generate a Venmo access token. This
      can be a bit tricky, but there is a rake task included with the Gem that
      should make the process easier. You'll also need to find your friends'
      Venmo IDs, which is also tricky but has an associated take task included.
      See the [documentation](https://github.com/stevenleeg/huginn_venmo_agent)
      for details on how to accomplish both of these.

      ## Event schema
      This agent accepts events in the following format:
      
          {
            "amount": 15.23,
            "user_id": "987435897345987",
            "note": "Some text goes here"
          }

      Regardless of the result, the agent will _not_ transmit any outgoing
      events. It will, however, log whether or not the query was successful.
    MD

    def working?
      true
    end


@@ 23,7 51,7 @@ module Agents

    def default_options
      {
        'venmo_token' => '{% credential VENMO_TOKEN %}',
        'venmo_token' => '{% credential venmo_token %}',
      }
    end


R lib/huginn_venmo_agent/venmo_timeline_agent.rb => lib/huginn_venmo_agent/read_venmo_timeline_agent.rb +35 -3
@@ 1,12 1,44 @@
module Agents
  class VenmoTimelineAgent < Agent
    API_BASE = 'https://api.venmo.com/v1'

  class ReadVenmoTimelineAgent < Agent
    include FormConfigurable

    API_BASE = 'https://api.venmo.com/v1'

    cannot_receive_events!
    can_dry_run!

    description <<-MD
      This agent connects your Huginn instance to the
      [unofficial Venmo API](https://github.com/mmohades/VenmoApiDocumentation),
      allowing you to periodically fetch your Venmo transaction timeline and
      emit events each time a new transaction is detected.

      Note that this agent requires you to generate a Venmo access token. This
      can be a bit tricky, but there is a rake task included with the Gem that
      should make the process easier. See the
      [documentation](https://github.com/stevenleeg/huginn_venmo_agent) for
      details.

      ## Event schema
      Each time a new transaction has been detected, this agent will emit an
      event containing the raw JSON payload returned by the API for the
      transaction. See the documentation for the
      [transactions list](https://github.com/mmohades/VenmoApiDocumentation#users-transactions-list)
      endpoint for details on what this contains.

      A few notable values within the tx payload:

      * `payment.amount` - The amount of money being sent/received.
      * `payment.status` - Will help you determine whether or not this is a
        pending request for money or a settled transaction.
      * `payment.action` - This, in combination with a key like `payment.actor.username`
        will help you determine whether or not the transaction is you
        requesting/sending money to someone else, or them requesting/sending
        money to you. If you're using this agent to sync transactions with some
        kind of ledger service, you'll generally need this information in order
        to determine whether or not the amount should be multiplied by -1.
    MD

    def working?
      true
    end