1.0.1 • Published 10 years ago

gocoin v1.0.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
10 years ago

gocoin-js

A JavaScript client library for the GoCoin API. It is written in CoffeeScript and is ready for use in both modern browsers and Node.js servers.

npm install gocoin

Examples

Example code Full API spec

Basic Usage

#coffee
GoCoin = require 'gocoin'
client = new GoCoin.Client()

client.setToken myAccessToken

client.users.self (err, user)->
  console.log user
  

##Xrate

#coffee
gocoin = new GoCoin.Client()
gocoin.xrate.get (err, resp) ->
  xrate = resp

Methods

Note: All callbacks follow the standard argument pattern of:

#js
  function(error, result) {}
#coffee
  (error, result) ->

Constructor

parameterdescriptiontypedefault value
loggerlogging function, must be an instance of winstonFunctioncustom logger
hostapi hoststring"api.gocoin.com"
secureSSL on or off, will default @port to 443 or 80booleantrue
portport to route requests through - supercedes "secure" parameterintegernull
pathused for prefixing routesstring"/api"
api_versionapi versionstring"v1"
methoddefault request methodstring"GET"
headersadd a header to all requestsobjectnull
parse_jsonwhen true, this automatically parses responses as JSONstringtrue
request_idinclude a request_id with every request - useful for debuggingstringnull
#coffee
gocoin = new GoCoin.Client
  secure: true
  parse_json: true
  request_id: "12345"

Client

client.setToken(access_token)

Stores the access token for use with all requests

client.getToken()

Will return the client instance access token

client.getCodeUrl(params)

Returns the Authorization Code URL

#coffee
params = {
  client_id: <application id>,
  response_type: 'code'
  redirect_uri: <application redirect uri>
  scope: "user_read invoice_read_write"
  state: <optional string>
}
url = gocoin.getCodeUrl params

client.authenticate(params, callback)

Obtains an access token

params = {
  client_id: <application id>,
  client_secret: <application secret key>
  redirect_uri: <application redirect uri>
  grant_type: "authorization_code"
  code: <access token authorization code>
}
gocoin.authenticate params, (err, body) ->
  access_token = body.access_token
  #store access token in db (recommended) or instantiate token
  gocoin.setToken access_token
  #make other requests

Users

users.self(callback)
users.get(user_id, callback)
users.update(params, callback)
params = {id: user_id, data: <updated user obj>}
users.update_password(params, callback)
params = {
  id: user_id,
  data: {
    current_password: "password",
    password: "passwordtwo",
    password_confirmation: "passwordtwo"
  }
}

Merchants

merchants.get(merchant_id, callback)
merchants.update(params, callback)
params = {id: merchant_id, data: <updated merchant obj>}
merchants.getSplit(params, callback)
params = {id: merchant_id, currency_code: "BTC"}
merchants.updateSplit(params, callback)
params = {
  id: merchant_id,
  currency_code: "BTC"
  payment_crypto_split: 100
  }
merchants.getSettings(merchant_id, callback)
merchants.updateSettings(params, callback)
params = {id: merchant_id, data: <updated settings obj>}
merchants.listCurrencies(merchant_id, callback)

Accounts

accounts.list(merchant_id, callback)
accounts.getTransactions(params, callback)
params = {id: merchant_id, data: <optional search parameters>}

Invoices

invoices.create(params, callback)
params = {id: merchant_id, data: <invoice obj>}
invoices.get(params, callback)
params = {id: invoice_id, verbose: <optional boolean>}
invoices.search(params, callback)
params = {id: merchant_id, data: <optional search parameters>}
invoices.confirmPaymentMethod(params, callback)
params = {id: merchant_id, data: <updated invoice obj>}
invoices.fulfill(invoice_id, callback)
invoices.sendWebhook(params, callback)
params = {
  id: merchant_id,
  data: {
    event_type: "invoice_ready_to_ship",
    callback_url: "https://testurl.com"
  }
}

Payouts

payouts.get(params, callback)
params = {id: payout_id, verbose: <optional boolean>}
payouts.list(merchant_id, callback)

Xrate

xrate.get(callback)

License

Copyright 2013 GoCoin Pte. Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

1.0.1

10 years ago

1.0.0

10 years ago

0.4.8

10 years ago

0.4.7

10 years ago

0.4.6

11 years ago

0.4.5

11 years ago

0.4.4

11 years ago

0.4.3

11 years ago

0.4.2

11 years ago

0.4.0

11 years ago

0.3.16

11 years ago

0.3.14

11 years ago

0.3.12

11 years ago

0.3.10

11 years ago

0.3.8

11 years ago

0.3.6

11 years ago

0.3.4

11 years ago

0.3.2

11 years ago

0.3.0

11 years ago

0.2.16

12 years ago

0.2.14

12 years ago

0.2.12

12 years ago

0.2.10

12 years ago

0.2.8

12 years ago

0.2.6

12 years ago

0.2.2

12 years ago

0.2.0

12 years ago

0.1.18

12 years ago

0.1.16

12 years ago

0.1.14

12 years ago

0.1.12

12 years ago

0.1.10

12 years ago

0.1.8

12 years ago

0.1.6

12 years ago

0.1.4

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago