Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to use beta api, intergrated 5 options #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ var request = require('request');

module.exports = url2png;

function url2png(apiKey, privateKey) {
function url2png(apiKey, privateKey, type) {
var prefix = '//api.url2png.com/v6/';
var format = 'png'
var lib = {};

if(type == 'beta'){
prefix = '//beta.url2png.com/v6/';
}

function buildURL(url, options) {
options = options || {};
if(typeof url !== 'string') throw new Error('url should be of type string (something like www.google.com)');
Expand All @@ -17,6 +21,11 @@ function url2png(apiKey, privateKey) {
if(options.delay && typeof options.delay !== 'number') throw new Error('delay should be a number in seconds');
if(options.force && typeof options.force !== 'boolean') throw new Error('force should be a boolean');
if(options.protocol && options.protocol != 'https' && options.protocol != 'http') throw new Error('protocol should either be "https" or "http"');
if(options.user_agent && typeof options.user_agent !== 'string') throw new Error('user_agent should be user agent string');
if(options.unique && typeof options.unique !== 'string') throw new Error('unique should be a string');
if(options.accept_languages && typeof options.accept_languages !== 'string') throw new Error('accept_languages should be a string');
if(options.ttl && typeof options.ttl !== 'number') throw new Error('ttl should be a number');
if(options.custom_css_url && typeof options.custom_css_url !== 'string') throw new Error('custom_css_url should be a string');
options.protocol = options.protocol || '';

url = 'url=' + encodeURIComponent(url);
Expand Down