rubik-pact
Advanced tools
Comparing version 1.0.2 to 1.0.3
const { Kubik } = require('rubik-main'); | ||
const FormData = require('form-data'); | ||
const fetch = require('node-fetch'); | ||
@@ -6,3 +7,2 @@ const set = require('lodash/set'); | ||
const get = require('lodash/get'); | ||
const querystring = require('querystring'); | ||
@@ -69,3 +69,2 @@ const methods = require('./Pact/methods'); | ||
const url = this.getUrl({ path, params, host }); | ||
let method = 'GET'; | ||
@@ -75,10 +74,14 @@ if (!token) token = this.token; | ||
if (isObject(body)) { | ||
body = querystring.stringify(body); | ||
headers['content-type'] = 'application/x-www-form-urlencoded' | ||
let method = 'POST' | ||
if (body instanceof FormData) { | ||
Object.assign(headers, body.getHeaders()); | ||
} else if (isObject(body)) { | ||
body = JSON.stringify(body); | ||
headers['Content-Type'] = 'application/json'; | ||
} else { | ||
method = 'GET'; | ||
} | ||
if (body) method = 'POST'; | ||
const request = await fetch(url, { method, body, headers }); | ||
// console.log(await request.text()); | ||
const result = await request.json(); | ||
@@ -85,0 +88,0 @@ |
module.exports = [ | ||
{ kubikName: 'companies.channels.conversations', apiName: 'companies/{{companyId}}/channels/{{channelId}}/conversations' }, | ||
{ kubikName: 'companies.conversations.messages', apiName: 'companies/{{companyId}}/conversations/{{conversationId}}/messages' }, | ||
{ kubikName: 'companies.conversations.messages.attachments', apiName: 'companies/{{companyId}}/conversations/{{conversationId}}/messages/attachments' }, | ||
{ kubikName: 'companies.conversationsGet', apiName: 'companies/{{companyId}}/conversations/{{conversationId}}' } | ||
]; |
{ | ||
"name": "rubik-pact", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Pact Bot Api kubik for the Rubik application system", | ||
@@ -21,2 +21,3 @@ "main": "classes/Pact.js", | ||
"dependencies": { | ||
"form-data": "^4.0.0", | ||
"lodash": "^4.17.15", | ||
@@ -23,0 +24,0 @@ "node-fetch": "^2.6.0" |
20423
188
4
+ Addedform-data@^4.0.0
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)