GithubHelp home page GithubHelp logo

vestorly-ruby's Introduction

VestorlyApi

Gem Version

The Vestorly API provides the ability for external developers to synchronize their client data with Vestorly.

Installation

Add this line to your application's Gemfile:

gem 'vestorly_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install vestorly_api

Running the tests

rspec

Basic Setup

To setup the client, you'll need the following configuration.

Rails example

VestorlyApi.configure do |config|
  config.api_uri = ENV['VESTORLY_API_URI']
end

SignIn to Vestorly API

Sign in will return the authentication token on success, and if the sign_in is invalid, it will raise VestorlyApi::Exceptions::InvalidSignInCredentials

Example: Authentication to the API

sign_in_api = VestorlyApi::SignIn.new('[email protected]', 'password')

begin
  authentication_token = sign_in_api.sign_in # vestorly-auth
rescue VestorlyApi::Exceptions::InvalidSignInCredentials
  # Do rescue stuff...
end

VestorlyApi::SignIn also provides the following public methods usable after the sign_in was successful:

sign_in_api.authentication_token # vestorly-auth
sign_in_api.advisor_id # advisor id

Using the advisor API object

Once logged in with a valid sign_in object, it can be passed to the VestorlyApi::Advisor to request on the advisor API part:

Example: Obtain the list of prospective clients for the logged in advisor

sign_in_api = VestorlyApi::SignIn.new('[email protected]', 'password')
sign_in_api.sign_in

advisor_api = VestorlyApi::Advisor.new(sign_in_api)
advisor_user_entries = advisor_api.advisor_user_entries

# with query params
query_params_hash = { 'filter_by' => 'prospects' }
advisor_user_entries = advisor_api.advisor_user_entries( query_params_hash )

Example: Return a list of active advisor accounts

sign_in_api = VestorlyApi::SignIn.new('[email protected]', 'password')
sign_in_api.sign_in

advisor_api = VestorlyApi::Advisor.new(sign_in_api)
advisor_posts = advisor_api.advisor_posts

# with query params
query_params_hash = { 'filter_by' => 'prospects' }
advisor_posts = advisor_api.advisor_posts(query_params_hash)

Example: Creating a new reader for the advisor

require 'vestorly_api'

sign_in_api = VestorlyApi::SignIn.new('[email protected]', 'password')
sign_in_api.sign_in

advisor_api = VestorlyApi::AdvisorBase.new(sign_in_api)

new_member_params = {
  email: "[email protected]",
  first_name: "Love",
  group_id: "541c9e06c3b5a0bdda000001",
  last_name: "Craft"
}

new_member = advisor_api.create_member( new_member_params )

NB: The examples above asume the sign_in was successful

Sign out of Vestorly API

To sign out of the Vestorly API we can use the VestorlyApi::SigOut object

Example: The sign out can be call in the 2 following forms

# Creating an object and calling sign_out method
response = VestorlyApi::SignOut.new(authentication_token).sign_out

# Calling sig_out method on the class
response = VestorlyApi::SignOut.sign_out(authentication_token)

# response is a hash containing code and message keys
p response # { code: 202, message: "Successfully logged out." }

# with invalid authentication token
p response # { code: 404, message: "Not signed in. }

Dependencies

Ruby

ruby 2.1.1p76

License

Licensed under MIT License

Contributing

  1. Fork it ( http://github.com//vestorly_api/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

vestorly-ruby's People

Contributors

ddre54 avatar

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.