Code Monkey home page Code Monkey logo

lunchmoney's Introduction

lunchmoney

Gem Version CI Yard Docs Maintainability Test Coverage

Buy Me A Coffee

This gem is a API client library of the LunchMoney API for the wonderful LunchMoney web app for personal finance & budgeting.

Documentation is still a work in process, but you can find the yard docs for this gem here as well as some write ups of the basics below. An example of every call is listed on the Api class in the yard docs.

Usage

Installation

Add this line to your application's Gemfile:

gem "lunchmoney"

Set your lunchmoney token

There are a few ways you can set your API token. You can set it manually using a configure block:

LunchMoney.configure do |config|
  config.api_key = "your_api_key"
end

The config will also automatically pull in the token if set via environment variable named LUNCHMONEY_TOKEN

You can also override the config and set your LunchMoney token for a specific API instance via kwarg:

LunchMoney::Api.new(api_key: "your_api_key")

Using the API

It is intended that all calls typically go through a LunchMoney::Api instannce. This class delegates methods to their relvant classes behind the scenes. Create an instance of the api, then call the endpoint you need:

api = LunchMoney::Api.new
api.categories

When the api returns an error a LunchMoney::Errors object will be returned. You can check the errors that occured via .messages on the instance. This will return an array of errors.

api = LunchMoney::Api.new
response = api.categories

response.class
=> LunchMoney::Errors

response.messages
=> ["Some error returned by the API"]

The instance itself has been set up to act like an array, delegating a lot of common array getter methods directly to messages for you. This enables things like:

api = LunchMoney::Api.new
response = api.categories

response.class
=> LunchMoney::Errors

response.first
=> "Some error returned by the API"

response.empty?
=> false

response[0]
=> "Some error returned by the API"

Contributing to this repo

Feel free to contribute and submit PRs to improve this gem

Releasing a new gem version

  1. Bump the VERSION constant in lib/lunchmoney/version.rb
  2. Run bundle install
  3. Commit and push up the change in a PR
  4. Merge the PR
  5. Create a new tag and release with the name version as v0.0.0
  6. A Github action will kick off and publish the new gem version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.