1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.MySampleAPI = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2 | var API = {
|
3 | debug: false,
|
4 |
|
5 | hello: function hello(data, headers, done) {
|
6 | if (!done && typeof headers === 'function') {
|
7 | done = headers;
|
8 | headers = null;
|
9 | }
|
10 |
|
11 | if (!done && this.debug) {
|
12 | console.warn('No callback supplied.');
|
13 | }
|
14 |
|
15 | $.ajax({
|
16 | method: 'GET',
|
17 | url: 'http://localhost:8000/hello',
|
18 | data: 'GET' === 'GET' ? data : JSON.stringify(data),
|
19 | contentType: 'application/json; charset=utf-8',
|
20 | beforeSend: function (xhr) {
|
21 | for (var key in headers) {
|
22 | xhr.setRequestHeader(key, headers[key]);
|
23 | }
|
24 | },
|
25 | complete: function(data) {
|
26 | if (data.responseJSON) {
|
27 | if (data.responseJSON.errorMessage) {
|
28 | typeof done === 'function' && done(data.responseJSON, null);
|
29 | } else {
|
30 | typeof done === 'function' && done(null, data.responseJSON);
|
31 | }
|
32 | } else {
|
33 | typeof done === 'function' && done(new Error('Could not complete network request.'));
|
34 | }
|
35 | }
|
36 | });
|
37 | },
|
38 | helloWorld: function helloWorld(data, headers, done) {
|
39 | if (!done && typeof headers === 'function') {
|
40 | done = headers;
|
41 | headers = null;
|
42 | }
|
43 |
|
44 | if (!done && this.debug) {
|
45 | console.warn('No callback supplied.');
|
46 | }
|
47 |
|
48 | $.ajax({
|
49 | method: 'POST',
|
50 | url: 'http://localhost:8000/hello/world',
|
51 | data: 'POST' === 'GET' ? data : JSON.stringify(data),
|
52 | contentType: 'application/json; charset=utf-8',
|
53 | beforeSend: function (xhr) {
|
54 | for (var key in headers) {
|
55 | xhr.setRequestHeader(key, headers[key]);
|
56 | }
|
57 | },
|
58 | complete: function(data) {
|
59 | if (data.responseJSON) {
|
60 | if (data.responseJSON.errorMessage) {
|
61 | typeof done === 'function' && done(data.responseJSON, null);
|
62 | } else {
|
63 | typeof done === 'function' && done(null, data.responseJSON);
|
64 | }
|
65 | } else {
|
66 | typeof done === 'function' && done(new Error('Could not complete network request.'));
|
67 | }
|
68 | }
|
69 | });
|
70 | },
|
71 | helloThere: function helloThere(data, headers, done) {
|
72 | if (!done && typeof headers === 'function') {
|
73 | done = headers;
|
74 | headers = null;
|
75 | }
|
76 |
|
77 | if (!done && this.debug) {
|
78 | console.warn('No callback supplied.');
|
79 | }
|
80 |
|
81 | $.ajax({
|
82 | method: 'DELETE',
|
83 | url: 'http://localhost:8000/hello/there',
|
84 | data: 'DELETE' === 'GET' ? data : JSON.stringify(data),
|
85 | contentType: 'application/json; charset=utf-8',
|
86 | beforeSend: function (xhr) {
|
87 | for (var key in headers) {
|
88 | xhr.setRequestHeader(key, headers[key]);
|
89 | }
|
90 | },
|
91 | complete: function(data) {
|
92 | if (data.responseJSON) {
|
93 | if (data.responseJSON.errorMessage) {
|
94 | typeof done === 'function' && done(data.responseJSON, null);
|
95 | } else {
|
96 | typeof done === 'function' && done(null, data.responseJSON);
|
97 | }
|
98 | } else {
|
99 | typeof done === 'function' && done(new Error('Could not complete network request.'));
|
100 | }
|
101 | }
|
102 | });
|
103 | },
|
104 | helloThere: function helloThere(data, headers, done) {
|
105 | if (!done && typeof headers === 'function') {
|
106 | done = headers;
|
107 | headers = null;
|
108 | }
|
109 |
|
110 | if (!done && this.debug) {
|
111 | console.warn('No callback supplied.');
|
112 | }
|
113 |
|
114 | $.ajax({
|
115 | method: 'PATCH',
|
116 | url: 'http://localhost:8000/hello/there',
|
117 | data: 'PATCH' === 'GET' ? data : JSON.stringify(data),
|
118 | contentType: 'application/json; charset=utf-8',
|
119 | beforeSend: function (xhr) {
|
120 | for (var key in headers) {
|
121 | xhr.setRequestHeader(key, headers[key]);
|
122 | }
|
123 | },
|
124 | complete: function(data) {
|
125 | if (data.responseJSON) {
|
126 | if (data.responseJSON.errorMessage) {
|
127 | typeof done === 'function' && done(data.responseJSON, null);
|
128 | } else {
|
129 | typeof done === 'function' && done(null, data.responseJSON);
|
130 | }
|
131 | } else {
|
132 | typeof done === 'function' && done(new Error('Could not complete network request.'));
|
133 | }
|
134 | }
|
135 | });
|
136 | },
|
137 | };
|
138 |
|
139 | if (window) window.MySampleAPI = API;
|
140 | module.exports = API;
|
141 |
|
142 | },{}]},{},[1])(1)
|
143 | }); |
\ | No newline at end of file |