VestorlyApi
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('my@user.com', 'password')
begin
authentication_token = sign_in_api.sign_in
rescue VestorlyApi::Exceptions::InvalidSignInCredentials
end
VestorlyApi::SignIn
also provides the following public methods usable after the sign_in was successful:
sign_in_api.authentication_token
sign_in_api.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('my@user.com', 'password')
sign_in_api.sign_in
advisor_api = VestorlyApi::Advisor.new(sign_in_api)
advisor_user_entries = advisor_api.advisor_user_entries
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('my@user.com', 'password')
sign_in_api.sign_in
advisor_api = VestorlyApi::Advisor.new(sign_in_api)
advisor_posts = advisor_api.advisor_posts
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('my@user.com', 'password')
sign_in_api.sign_in
advisor_api = VestorlyApi::AdvisorBase.new(sign_in_api)
new_member_params = {
email: "lovecraft@gmail.com",
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
response = VestorlyApi::SignOut.new(authentication_token).sign_out
response = VestorlyApi::SignOut.sign_out(authentication_token)
p response
p response
Dependencies
Ruby
ruby 2.1.1p76
Contributing
- Fork it ( http://github.com//vestorly_api/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request