CyberbizExpress
Ninja Van API Document: https://api-docs.ninjavan.co/en
Installation
Add this line to your application's Gemfile:
gem 'cyberbiz_express'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cyberbiz_express
Usage
Ninja Van
config/initializers/ninja_van.rb
require 'cyberbiz_express/ninja_van/ninja_van'
CyberbizExpress::NinjaVan.configure do |config|ÂÂÂÂ
config.client_id = SecretSetting.ninja_van.client_id
config.client_secret = SecretSetting.ninja_van.client_secret
config.api_url =
if Rails.env.production?
'https://api.ninjavan.co/my'
else
'https://api-sandbox.ninjavan.co/sg'
end
end
access_token
CyberbizExpress::NinjaVan::Api.new('ninja_van').access_token
submit_order
order = {
number: '1101',
email: '[email protected]',
line_items: [{ name: 'test1', quantity: 3 },{ name: 'test2', quantity: 1 }],
}
shipping_address = {
name: 'Jane Doe',
phone: '+60103067174',
email: 'sample_to@cyberbiz,io',
address1: 'Jalan PJU 8/8',
address2: '',
district: 'Damansara Perdana',
city: 'Petaling Jaya',
province: 'Selangor',
location: 'MY',
zip_code: '47820',
}
shop = {
id: 24719,
name: 'My Shop',
phone: '+60138201527',
email: 'sample@cyberbiz,io',
address: '17 Lorong Jambu 3',
district: 'Taman Sri Delima',
city: 'Simpang Ampat',
province: 'Pulau Pinang',
location: 'MY',
zip_code: '51200',
}
= {
service_type: 'Parcel',
pickup_date: '2024-12-31',
pickup_start_time: '09:01',
pickup_end_time: '13:31',
delivery_date: '2025-01-12',
delivery_start_time: '09:01',
delivery_end_time: '13:31',
insured_value: 300.21,
total_weight: 4.5,
pickup_instructions: 'If recipient is not around, leave parcel in power riser.',
delivery_instructions: 'Hello Ninja Van!',
}
CyberbizExpress::NinjaVan::Api.new('ninja_van', access_token: access_token).submit_order(order, shipping_address, shop, )
update_order
CyberbizExpress::NinjaVan::Api.new('ninja_van', access_token: access_token).update_order('CYB14530O1103', {})
cancel_order
CyberbizExpress::NinjaVan::Api.new('ninja_van', access_token: access_token).cancel_order('FF0194810413', {}, {}, {})