Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

Commit

Permalink
Pass options to resourceCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpsi committed Mar 16, 2017
1 parent 18f6fa1 commit 7174a6c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions readme.md
@@ -1,5 +1,9 @@
# Transifex-js-client


[![NPM](https://nodei.co/npm/github-webhook-handler.png?downloads=true&downloadRank=true)](https://nodei.co/npm/github-webhook-handler/)
[![NPM](https://nodei.co/npm-dl/github-webhook-handler.png?months=6&height=3)](https://nodei.co/npm/github-webhook-handler/)

[![MIT License][license-badge]][LICENSE]
[![Build Status](https://travis-ci.org/transifex/transifex-js-client.svg?branch=master)](https://travis-ci.org/transifex/transifex-js-client)
[![Coverage Status](https://coveralls.io/repos/github/transifex/transifex-js-client/badge.svg?branch=master)](https://coveralls.io/github/transifex/transifex-js-client?branch=master)
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Expand Up @@ -15,7 +15,7 @@ const strToHash = (source_string) => md5((unescape(encodeURIComponent(source_str
module.exports = function(options) {
const opts = {};
/* istanbul ignore next */
const baseURL = options.base_url || 'https://www.transifex.com';
const baseURL = options.base_url; // || 'https://www.transifex.com';
opts.headers = { 'Content-Type': 'application/json' };

if (options.username) {
Expand All @@ -36,7 +36,8 @@ module.exports = function(options) {
const axios_client = axios.create(opts);
const url_map = require('./url.js')(baseURL + api_prefix);

return extend({},
return extend(
{ urls: url_map },
Project(axios_client, url_map),
Language(axios_client, url_map),
LanguageInfo(axios_client, url_map),
Expand Down
18 changes: 16 additions & 2 deletions src/mixins/resource.js
Expand Up @@ -31,10 +31,10 @@
})
**/

resourceCreate(project_slug, form) {
resourceCreate(project_slug, form, options) {
var path = urls['resources'].
replace('<project_slug>', project_slug);
return axios.post(path, form);
return axios.post(path, form, options);
},

/**
Expand All @@ -51,6 +51,20 @@
return axios.get(path);
},

/**
* Retrieves the source file of the resource
* @param {string} project_slug - The projects slug
* @param {string} resource_slug - The resource slug
* @example txApi.resourceFile('autotest', 'resourcetest')
**/

resourceFile(project_slug, resource_slug) {
var path = urls['resourceUpdate'].
replace('<project_slug>', project_slug).
replace('<resource_slug>', resource_slug);
return axios.get(path, { params: { file: true } });
},

/**
* Update the details of an existing resource
* @param {string} project_slug - The projects slug
Expand Down

0 comments on commit 7174a6c

Please sign in to comment.