roketin-connect v2.15.3
Introduction
This is a Promise based plugin for connecting between your vue/nuxt project and roketin api with ease.
Initialization
Create config file on /plugins, for example 'r-connect.config.js'
add this command
var Roketin = require('roketin-connect')
Roketin.connect({
api_key: '$2y$10$14Mn3dBBLZllrXoHlrQsT.TWlzCh33KFjbGzw3lNzfETsbuhjphaW',
env: 'development'
})
include in nuxt.config.js
plugins: [
'~/plugins/r-connect.config.js',
]
Important! To get api key you must contact roketin administrator
#Usage
Example
In this example, we will learn how to fetch Page detail in your nuxt application
Without Vuex
This will call the plugin directly from your .vue file
import roketin from 'roketin-connect'
export default {
data () {
return {
page: {}
}
}
created () {
roketin.get.website.category.list()
.then(response => {
this.page = response.data
})
.catch(err => {
console.log(err)
})
}
}
With Vuex (Recommended)
Implementation in Vuex is so easy, you just need two steps. First, create a file in store named 'pages.js'.
In pages.js, write the following code
import roketin from 'roketin-connect'
export const state = () => {
page: {}
}
export const actions = {
getPageCategories: ({commit}) => (
roketin.get.page.category.list().then(response => {
if (response) {
commit('getPageCategories', response.data)
}
})
.catch(error => {
console.log('error', error)
})
)
}
export const mutations = {
getPageCategories: (state, payload) => {
state.page = payload
}
}
finally, let's try to call the action in your .vue file
created () {
this.$store.dispatch('pages/getPageCategories')
}
computed: {
page () {
return this.$store.state.pages.page
}
}
Library
1. Product Management
Attributes
- All Attributes
roketin.get.product.attribute.list()
- Search Attributes
/**
* @param {string} query
* @param {integer} take
**/
roketin.search.product.attribute.with.params({
query: 'a',
take: 1
})
- Attribute detail
/**
* @param {string} id
**/
let id = '5b7bb141754c3d420314693b
roketin.get.product.attribute.with.id(id)
- Update Attribute
/**
* @param {string} type
* @param {object} images
**/
let id = '5b7bb141754c3d420314693b
let newData = {
"type": "slider",
"images": [
{
"image": "http://r-document.roketin.xyz/storage/images/180820091239-350x200.png",
"title": "celana",
"description": "description",
"url": "desc"
}
]
}
roketin.update.product.attribute.with.id(id).to(newData)
- Destroy Attribute
/**
* @param {string} id
**/
let id = '5b7bb141754c3d420314693b
roketin.destroy.product.attribute.with.id(id)
Brands
- Create New Brand
/**
* @param {string} name
**/
roketin.create.product.brand({
name: 'New brand'
})
- All Brands
/**
* @param {int} paginate
* @param {int} per_page
* @param {int} page
**/
roketin.get.product.brands({
paginate: 1,
per_page: 1,
page: 1
})
- Table Brands
/**
* @param {int} paginate
* @param {int} size
**/
roketin.get.product.brand.table({
paginate: 1,
size: 5
})
- Brand Detail
/**
* @param {string} id
**/
let id = '5b7bb141754c3d420314693b'
roketin.get.product.brand.with.id(id)
- Update Brand
/**
* @param {object} data
* data is the updated brand data
* @param {string} id
**/
roketin.update.product.brand.with.id(id).to(data)
- Destroy Brand
/**
* @param {string} id
**/
roketin.destroy.product.brand.with.id(id)
Categories
- All Categories
/**
* @param {int} per_page
* @param {int} paginate
* @param {int} page
**/
roketin.get.product.categories({
per_page: 1,
paginate: 1,
page: 2
})
- Category Detail
/**
* @param {string} id
**/
let id = '5b8659a9754c3d39b6065ae2'
roketin.get.product.category.with.id(id)
- Create New Category
/**
* @param {string} name
**/
roketin.get.product.category.with.id({
name: 'New Category'
})
- Update Category
/**
* @param {string} id
* @param {string} name
**/
roketin.update.product.category.with.id('5b8659a9754c3d39b6065ae2').to({
name: 'Category 3'
})
- Destroy Category
/**
* @param {string} id
**/
let id = '5b8659a9754c3d39b6065ae2'
roketin.destroy.product.category.with.id(id)
Products
- All Products
/**
* @param {int} per_page
* @param {int} paginate
* @param {int} page
**/
roketin.get.product.list({
per_page: 1,
paginate: 1,
page: 2
})
- All Products with tags
/**
* @param {array} tags
**/
let tags = ['deals-discount', 'tour']
roketin.get.product.list(tags)
- All Products with sorting
/**
* @param {object} sorts
* @param {string} by - desc or asc
* @param {string} column - column name
**/
roketin.get.product.list({
per_page: 1,
paginate: 1,
page: 2,
sorts: [{
column: 'name',
by: 'asc'
}]
})
- Autocomplete Products
/**
* @param {string} name
**/
roketin.autocomplete.product.with.name('a')
- Table Products
/**
* @param {int} per_page
**/
roketin.get.product.table({
per_page: 1
})
Product Detail
/**
* @param {string} id
**/
roketin.get.product.with.id('5b7bb141754c3d420314693b')
Update Product
/**
* @param {string} id
* @param {object} newData
**/
roketin.destroy.product.with.id(id).to(newData)
Destroy Product
/**
* @param {string} id
**/
roketin.destroy.product.with.id('5b7bb141754c3d420314693b')
2. Website Management
Pages
- All Pages
/**
* @param {int} per_page
* @param {int} paginate
* @param {int} page
**/
roketin.get.website.page.list({
per_page: 10,
paginate: 1,
page: 2
})
- Page detail
/**
* @param {string} id
**/
roketin.get.website.page.with.id('5b7bb141754c3d420314693b')
- Create Page
/**
* @param {object} data
**/
let data = {
"title" : "Title Picture",
"slug" : "slug-picture",
"category_id": "xxxxxxxxxx",
"sections" : [
{
"type" : "slider",
"order" : "",
"title" : "",
"subtitle" : "",
"url" : "",
"use_button" : false,
"text_button" : "",
"images_detail" : [
{
"image" : {
"upload" : {
"uuid" : "dd2a2a6d-6d78-4c4c-a18e-613a6159bc0d",
"progress" : 100,
"total" : 18192,
"bytesSent" : 18192,
"filename" : "648d6f9d7ed1b14ada078a5191280db7.jpg",
"chunked" : false,
"totalChunkCount" : 1
},
"status" : "success",
"previewElement" : [],
"previewTemplate" : [],
"accepted" : true,
"processing" : true,
"xhr" : [],
"dataURL" : ""
"width" : 450,
"height" : 450
}
}
],
"temporary_id" : [
"5acf34f5754c3d5fff3ee6b3"
]
}
],
"status" : 0
}
roketin.create.page.item(data)
- Update Page
/**
* @param {string} id
* @param {object} newData
**/
let newData = {
name: "Hari Raya Aja Episode 3"
from_date: "2018-01-29"
until_date: "2018-01-28"
description: "bla bla bla bla bla"
status: 1
workday_cut: 1
}
let id = '5b7bb141754c3d420314693b'
roketin.update.website.page.with.id(id).to(newData)
- Destroy Page
/**
* @param {string} id
**/
let id = '5b7bb141754c3d420314693b'
roketin.destroy.website.page.with.id('5b7bb141754c3d420314693b')
Posts
- Get Post List
roketin.get.website.post.list()
- Get Post Detail
/**
* @param {string} id
**/
let id = '127cb141754c3d42241469bn'
roketin.get.website.post.with.id(id)
- Create Post
/**
* Create post with page id
* @param {string} page_id Page id, must be exist
* @param {string} title Title of the post
**/
roketin.create.website.post.({
page_id,
title
})
- Update Post
/**
* Update post with certain id to new value
* @param {string} id, the id of the post
* @param {object} new_data, new value to be updated
**/
let new_data = {
page_id: 5aba1456c7606d18c76b1000,
title: 'New Post Name'
}
roketin.update.page.post.with.id(id).to(new_data)
- Destroy Post
/**
* Destroy post with certain id
* @param {string} id
**/
let id = '127cb141754c3d42241469bn'
roketin.destroy.website.post.with.id(id)
3. Marketing Management
Voucher
- Get Voucher List
roketin.get.voucher.list()
- Get Voucher Detail
/**
* @param {string} id
**/
let id = '5b4c576806738a76e94a0d74'
roketin.get.voucher.with.id(id)
- Check Voucher
/**
* @param {object} params
**/
let params = {
code: 'aaa',
total_purchase: 1
}
roketin.check.voucher.with.params(params)
3. Order Management
Sales Invoices
Get Sales Invoice
/**
* @params {string} sales_order - get sales invoice list with sales order id
**/
roketin.get.sales_invoice.list({
sales_order: '8b0aa00f-17fe-42fa-bfb7-a25de7382370'
})
- Get Sales Invoice Detail
/**
* @params {string} id - sales invoice id
**/
roketin.get.sales_invoice.with.id('8be24169-740d-4315-a07b-da5699a78779')
- Get Sales invoice with number Get sales invoice with specific number
/**
* @params {string} number - sales invoice number
* @returns {object} - if sales invoice with that name not found, it returns empty object, otherwise it returns the object filled with sales invoice
**/
roketin.get.sales_invoice.with.number('SI2018092700004')
Sales Orders
- Get Sales Order
roketin.get.order.salesOrder.list()
- Create Sales Order
roketin.create.order.salesOrders({
"member_id": null,
"order_at": "2009-09-09",
"is_create_invoice": true,
"due_date_invoice": "2009-09-09",
"message_from_customer": "pesan",
"name": "adin",
"email": "iman@roketin.com",
"phone": "123123123",
"address": "Bandung",
"send_invoice": false,
"expedition_code": "jne",
"service_code": "oke",
"discounts": 10000,
"voucher_code": null,
"tax": 10,
"shipping_cost": 0,
"sender_id": null,
"products": [
{
"name": "Sendal Merah",
"product_id": "5b9008d46f6bfc1318003619",
"quantity": 1,
"price": 30000,
"discount": 0,
"add_cost": 0,
"weight": 100
},
{
"name": "Swallow",
"product_id": "5b9008d46f6bfc131800361a",
"quantity": 1,
"price": 50000,
"discount": 0,
"add_cost": 0,
"weight": 100
}
]
})
4. Company Management
Social Media
- Get Company Social Media List
roketin.get.company.social_media.list()
Bank
- Get Company Bank List
roketin.get.company.bank.list()
5. Configuration Management
Bank
- Get Bank List This will get every bank list
roketin.get.configuration.bank.list()
Social Media
- Get Social Media List This will get every available social media
roketin.get.configuration.social_media.list()
6. Document Management
Temporary Image
Upload Temporary Image
/**
* @params {file} file
**/
roketin.create.temporary_image(file)
For example: On your vue file
<template>
<div>
<input type="file" @change="uploadTemporaryFile">
</div>
</template>
<script>
export default {
methods: {
uploadTemporaryFile (file) {
this.$store.dispatch('image/uploadTemporaryFile', file)
}
}
}
</script>
On your store/image file
export const actions = {
uploadTemporaryFile (file) {
roketin.create.temporary_image(file)
.then (response => {
//
})
.catch (error => {
//
})
}
}
New function coming soon!
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago