Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Latest commit

 

History

History
45 lines (27 loc) · 1.67 KB

File metadata and controls

45 lines (27 loc) · 1.67 KB

This gem provides access to Vend’s REST API.

At the time of writing, this is located at developers.vendhq.com/documentation

You will need to implement the following steps to connect your application to a Vend Retailer account.

auth_code = Vend::Oauth2::AuthCode.new(STORE, CLIENT_ID, SECRET, REDIRECT_URI)
url = auth_code.authorize_url

Url will look like:

https://secure.vendhq.com/connect?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}&state={state}

After successful authorisation, you will be redirected to:

{redirect_uri}?code={code}&domain_prefix={domain_prefix}&state={state}
auth_code = Vend::Oauth2::AuthCode.new(STORE, CLIENT_ID, SECRET, REDIRECT_URI)
token = auth_code.token_from_code(params[:code])

Where token is an instance of OAuth2::AccessToken www.rubydoc.info/gems/oauth2/1.0.0/OAuth2/AccessToken

client = Vend::Oauth2::Client.new(STORE, AUTH_TOKEN)
client.Product.all.each do |product|
  puts product.name
end
auth_code = Vend::Oauth2::AuthCode.new(STORE, CLIENT_ID, SECRET, REDIRECT_URI)
token = auth_code.refresh_token(auth_token, refresh_token)

The response payload may include a refresh token, if so, you need to update your currently stored refresh token.