sharetribe-flex-sdk 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/.circleci/config.yml +22 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +19 -0
  4. package/CHANGELOG.md +231 -0
  5. package/LICENSE +201 -0
  6. package/README.md +76 -0
  7. package/build/sharetribe-flex-sdk-node.js +13592 -0
  8. package/build/sharetribe-flex-sdk-web.js +1 -0
  9. package/docs/README.md +20 -0
  10. package/docs/authentication.md +179 -0
  11. package/docs/calling-the-api.md +217 -0
  12. package/docs/configurations.md +95 -0
  13. package/docs/developing-sdk.md +131 -0
  14. package/docs/docpress.json +14 -0
  15. package/docs/features.md +14 -0
  16. package/docs/keep-alive.md +48 -0
  17. package/docs/object-query-parameters.md +36 -0
  18. package/docs/scripts.js +41 -0
  19. package/docs/serializing-types-to-json.md +40 -0
  20. package/docs/sharing-session-between-client-and-server.md +19 -0
  21. package/docs/styles.css +95 -0
  22. package/docs/token-store.md +114 -0
  23. package/docs/try-it-in-browser.md +32 -0
  24. package/docs/try-it-in-the-playground.md +153 -0
  25. package/docs/types.md +27 -0
  26. package/docs/writing-your-own-token-store.md +29 -0
  27. package/docs/your-own-types.md +61 -0
  28. package/examples/README.md +5 -0
  29. package/examples/getting-started-browser/README.md +22 -0
  30. package/examples/getting-started-browser/index.html +89 -0
  31. package/examples/getting-started-browser/index.js +156 -0
  32. package/examples/getting-started-browser/screenshots/screenshot1.png +0 -0
  33. package/examples/getting-started-browser/screenshots/screenshot2.png +0 -0
  34. package/examples/getting-started-node/README.md +23 -0
  35. package/examples/getting-started-node/index.js +139 -0
  36. package/examples/getting-started-node/screenshots/screenshot.png +0 -0
  37. package/package.json +83 -0
  38. package/playground.js +295 -0
  39. package/src/browser_cookie_store.js +26 -0
  40. package/src/context_runner.js +151 -0
  41. package/src/context_runner.test.js +185 -0
  42. package/src/detect.js +11 -0
  43. package/src/express_cookie_store.js +57 -0
  44. package/src/fake/adapter.js +130 -0
  45. package/src/fake/api.js +137 -0
  46. package/src/fake/auth.js +84 -0
  47. package/src/fake/token_store.js +231 -0
  48. package/src/index.js +25 -0
  49. package/src/interceptors/.eslintrc.js +5 -0
  50. package/src/interceptors/add_auth_header.js +32 -0
  51. package/src/interceptors/add_auth_header.test.js +50 -0
  52. package/src/interceptors/add_auth_token_response.js +16 -0
  53. package/src/interceptors/add_client_id_to_params.js +12 -0
  54. package/src/interceptors/add_client_secret_to_params.js +15 -0
  55. package/src/interceptors/add_grant_type_to_params.js +23 -0
  56. package/src/interceptors/add_idp_client_id_to_params.js +17 -0
  57. package/src/interceptors/add_idp_id_to_params.js +17 -0
  58. package/src/interceptors/add_idp_token_to_params.js +17 -0
  59. package/src/interceptors/add_scope_to_params.js +18 -0
  60. package/src/interceptors/add_subject_token_to_params.js +18 -0
  61. package/src/interceptors/add_token_exchange_grant_type_to_params.js +12 -0
  62. package/src/interceptors/auth_info.js +50 -0
  63. package/src/interceptors/clear_token_after_revoke.js +45 -0
  64. package/src/interceptors/default_params.js +12 -0
  65. package/src/interceptors/fetch_auth_token_from_api.js +33 -0
  66. package/src/interceptors/fetch_auth_token_from_store.js +27 -0
  67. package/src/interceptors/fetch_refresh_token_for_revoke.js +24 -0
  68. package/src/interceptors/multipart_request.js +35 -0
  69. package/src/interceptors/retry_with_anon_token.js +58 -0
  70. package/src/interceptors/retry_with_refresh_token.js +70 -0
  71. package/src/interceptors/save_token.js +20 -0
  72. package/src/interceptors/transit_request.js +27 -0
  73. package/src/interceptors/transit_request.test.js +58 -0
  74. package/src/interceptors/transit_response.js +27 -0
  75. package/src/memory_store.js +19 -0
  76. package/src/params_serializer.js +65 -0
  77. package/src/params_serializer.test.js +58 -0
  78. package/src/sdk.js +894 -0
  79. package/src/sdk.test.js +908 -0
  80. package/src/serializer.js +279 -0
  81. package/src/serializer.test.js +229 -0
  82. package/src/token_store.js +15 -0
  83. package/src/types.js +108 -0
  84. package/src/types.test.js +75 -0
  85. package/src/utils.js +68 -0
  86. package/src/utils.test.js +85 -0
  87. package/webpack.config.babel.js +47 -0
@@ -0,0 +1,22 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ branches:
5
+ ignore:
6
+ - gh-pages
7
+ docker:
8
+ - image: node:8.10.0
9
+ steps:
10
+ - checkout
11
+ - run:
12
+ name: install
13
+ command: yarn install
14
+ - run:
15
+ name: build
16
+ command: yarn run build
17
+ - run:
18
+ name: test
19
+ command: yarn test
20
+ - run:
21
+ name: lint
22
+ command: yarn run lint
package/.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ build/
2
+ node_modules/
3
+ docs/
package/.eslintrc.js ADDED
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ plugins: [
3
+ 'jest'
4
+ ],
5
+ extends: [
6
+ 'plugin:jest/recommended',
7
+ 'airbnb-base',
8
+ 'prettier',
9
+ ],
10
+ parserOptions: {
11
+ sourceType: 'module',
12
+ },
13
+ env: {
14
+ es6: true,
15
+ browser: false,
16
+ node: false,
17
+ jest: true
18
+ },
19
+ };
package/CHANGELOG.md ADDED
@@ -0,0 +1,231 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a
6
+ Changelog](http://keepachangelog.com/en/1.0.0/) and this project
7
+ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8
+
9
+ ## [Unreleased] - xxxx-xx-xx
10
+
11
+ ## [v1.14.0] - 2021-09-20
12
+
13
+ ### Added
14
+
15
+ - New endpoints [#142](https://github.com/sharetribe/flex-sdk-js/pull/142)
16
+ - `sdk.stockAdjustments.query(/* ... */)`
17
+ - `sdk.stockAdjustments.create(/* ... */)`
18
+ - `sdk.stock.compareAndSet(/* ... */)`
19
+
20
+ ### Changed
21
+
22
+ - Extend cookie expiration from 30 days to 180 days. This matches
23
+ with the lifetime of the refresh token returned by the Auth API.
24
+ [#138](https://github.com/sharetribe/flex-sdk-js/pull/138)
25
+ - SDK shows a warning if Client Secret is used in a browser.
26
+ [#134](https://github.com/sharetribe/flex-sdk-js/pull/134)
27
+
28
+ ### Security
29
+
30
+ - Update Axios to 0.21.1 [#126](https://github.com/sharetribe/flex-sdk-js/pull/126)
31
+ - Update Lodash to 4.17.21 [#131](https://github.com/sharetribe/flex-sdk-js/pull/131)
32
+ - Update development dependencies with security vulnerabilities (multiple PRs)
33
+
34
+ ## [v1.13.0] - 2020-10-15
35
+
36
+ ### Added
37
+
38
+ - New endpoints [#121](https://github.com/sharetribe/flex-sdk-js/pull/121)
39
+ - `sdk.loginWithIdp(/* ... */)`
40
+ - `sdk.currentUser.createWithIdp(/* ... */)`
41
+
42
+ ## [v1.12.0] - 2020-08-12
43
+
44
+ ### Added
45
+
46
+ - A utility function to convert an object query parameter into a URL compatible
47
+ string. [#119](https://github.com/sharetribe/flex-sdk-js/pull/119)
48
+
49
+ ## [v1.11.0] - 2020-06-16
50
+
51
+ This release just changes the version number, making the alpha release
52
+ into a proper release.
53
+
54
+ ## [v1.11.0-alpha-1] - 2020-06-11
55
+
56
+ ### Added
57
+
58
+ - Export Transit serialization helpers
59
+ [#113](https://github.com/sharetribe/flex-sdk-js/pull/113)
60
+
61
+ ## [v1.11.0-alpha] - 2020-05-08
62
+
63
+ ### Added
64
+
65
+ - New experimental method `exchangeToken`
66
+ [#110](https://github.com/sharetribe/flex-sdk-js/pull/110)
67
+
68
+ ## [v1.10.0] - 2020-02-28
69
+
70
+ ### Changed
71
+
72
+ - The JS SDK Repl environment replaced with a new API Playground
73
+ [#109](https://github.com/sharetribe/flex-sdk-js/pull/109)
74
+ - Support starting in an initialized and authenticated modes
75
+ - Support running scripts
76
+ - Add helpers and support all API value types
77
+
78
+ ## [v1.9.1] - 2020-02-18
79
+
80
+ ### Fixed
81
+
82
+ - Handling old API tokens that lack the `scope` attribute in `sdk.authInfo`
83
+ [#108](https://github.com/sharetribe/flex-sdk-js/pull/108)
84
+
85
+ ## [v1.9.0] - 2020-02-12
86
+
87
+ ### Added
88
+
89
+ - Support for logging in using an authorization code
90
+ [#107](https://github.com/sharetribe/flex-sdk-js/pull/107)
91
+
92
+ ### Changed
93
+
94
+ - `sdk.authInfo` return value has been updated
95
+ [#107](https://github.com/sharetribe/flex-sdk-js/pull/107). The `grantType`
96
+ attribute has been deprecated and now the returned attributes are:
97
+ - `isAnonymous`: a boolean denoting if the currently stored token only allows
98
+ public read access
99
+ - `scopes`: an array containing the scopes associated with the access token
100
+
101
+ ## [v1.8.0] - 2019-12-20
102
+
103
+ ### Changed
104
+
105
+ - Add endpoint [#105](https://github.com/sharetribe/flex-sdk-js/pull/105)
106
+ - `sdk.stripeAccount.fetch(/* ... */)`
107
+
108
+ ## [v1.7.0] - 2019-12-05
109
+
110
+ ### Changed
111
+
112
+ - Remove endpoint [#104](https://github.com/sharetribe/flex-sdk-js/pull/103)
113
+ - `sdk.stripeAccountData.fetch(/* ... */)`
114
+
115
+ ## [v1.6.0] - 2019-12-05
116
+
117
+ ### Added
118
+
119
+ - New endpoints [#103](https://github.com/sharetribe/flex-sdk-js/pull/103)
120
+ - `sdk.stripeAccountData.fetch(/* ... */)`
121
+ - `sdk.stripeAccountLinks.create(/* ... */)`
122
+
123
+ ## [v1.5.0] - 2019-08-21
124
+
125
+ ### Security
126
+
127
+ - Upgrade dependencies with security issues:
128
+ - Axios (thanks [@joekarasek](https://github.com/joekarasek)!) [#98](https://github.com/sharetribe/flex-sdk-js/pull/95)
129
+ - Docpress [#97](https://github.com/sharetribe/flex-sdk-js/pull/97)
130
+ - Jest and Babel [#96](https://github.com/sharetribe/flex-sdk-js/pull/96)
131
+ - all the patch and minor release updateds for all the dependencies [#101](https://github.com/sharetribe/flex-sdk-js/pull/101)
132
+
133
+ ### Added
134
+
135
+ - New endpoints [#100](https://github.com/sharetribe/flex-sdk-js/pull/100)
136
+ - `sdk.stripeSetupIntents.create(/* ... */)`
137
+ - `sdk.stripeCustomer.create(/* ... */)`
138
+ - `sdk.stripeCustomer.addPaymentMethod(/* ... */)`
139
+ - `sdk.stripeCustomer.deletePaymentMethod(/* ... */)`
140
+
141
+ ## [v1.4.0] - 2019-04-16
142
+
143
+ ### Added
144
+
145
+ - `sdkType` property to the type handler configuration. This property
146
+ replaces the deprecated `type`
147
+ property. [#94](https://github.com/sharetribe/flex-sdk-js/pull/94)
148
+ - `appType` property to the type handler configuration. This property
149
+ replaces the deprecated `customType`
150
+ property. [#94](https://github.com/sharetribe/flex-sdk-js/pull/94)
151
+ - `canHandle` property to the type handler configuration. The value is
152
+ expected to be a predicate function (i.e. function that returns
153
+ truthy or falsy values). If `canHandle` returns truthy value, the
154
+ writer function will called. This allows users to fully customize
155
+ how they use read and writer the data types to and from
156
+ SDK. [#94](https://github.com/sharetribe/flex-sdk-js/pull/94)
157
+ - Added information about the `canHandle` function in the "Your own
158
+ types"
159
+ document. [#94](https://github.com/sharetribe/flex-sdk-js/pull/94)
160
+
161
+ ### Deprecated
162
+
163
+ - `type` property in type handler configuration. Use `sdkType` instead.
164
+ - `customType` property in type handler configuration. Use `appType` instead.
165
+
166
+ ## [v1.3.0] - 2019-02-27
167
+
168
+ ### Added
169
+
170
+ - Missing step (copy sharetribe-flex-sdk-web.js from /build/ to /docs/)
171
+ - New endpoints [#92](https://github.com/sharetribe/flex-sdk-js/pull/92)
172
+ - `sdk.stripeAccount.create(/* ... */)`
173
+ - `sdk.stripeAccount.update(/* ... */)`
174
+ - `sdk.stripePersons.create(/* ... */)`
175
+
176
+ ### Changed
177
+
178
+ - Updated dependencies
179
+
180
+ ## [v1.2.0] - 2018-11-27
181
+
182
+ ### Added
183
+
184
+ - New endpoints [#89](https://github.com/sharetribe/flex-sdk-js/pull/89)
185
+ - `sdk.availabilityExceptions.create(/* ... */)`
186
+ - `sdk.availabilityExceptions.delete(/* ... */)`
187
+ - `sdk.availabilityExceptions.query(/* ... */)`
188
+ - `sdk.bookings.query(/* ... */)`
189
+
190
+ ### Changed
191
+
192
+ - Make `baseUrl` optional, defaults to `https://flex-api.sharetribe.com` [#90](https://github.com/sharetribe/flex-sdk-js/pull/90)
193
+
194
+ ## [v1.1.0] - 2018-11-07
195
+
196
+ ### Added
197
+
198
+ - New endpoints [#88](https://github.com/sharetribe/flex-sdk-js/pull/88)
199
+ - `sdk.ownListings.createDraft(/* ... */)`
200
+ - `sdk.ownListings.publishDraft(/* ... */)`
201
+ - `sdk.ownListings.discardDraft(/* ... */)`
202
+
203
+ ## v1.0.0 - 2018-08-07
204
+
205
+ This is the first version that is published in NPM.
206
+
207
+ See: https://www.npmjs.com/package/sharetribe-flex-sdk
208
+
209
+ ### Changed
210
+
211
+ - Updated dependencies
212
+ - Changed package name from `sharetribe-sdk` to `sharetribe-flex-sdk`
213
+ to prepare for publishing to NPM. Remember to check your existing
214
+ imports!
215
+
216
+ [v1.13.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.12.0...v1.13.0
217
+ [v1.12.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.11.0...v1.12.0
218
+ [v1.11.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.11.0-alpha-1...v1.11.0
219
+ [v1.11.0-alpha-1]: https://github.com/sharetribe/flex-sdk-js/compare/v1.11.0-alpha...v1.11.0-alpha-1
220
+ [v1.11.0-alpha]: https://github.com/sharetribe/flex-sdk-js/compare/v1.10.0...v1.11.0-alpha
221
+ [v1.10.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.9.1...v1.10.0
222
+ [v1.9.1]: https://github.com/sharetribe/flex-sdk-js/compare/v1.9.0...v1.9.1
223
+ [v1.9.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.8.0...v1.9.0
224
+ [v1.8.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.7.0...v1.8.0
225
+ [v1.7.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.6.0...v1.7.0
226
+ [v1.6.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.5.0...v1.6.0
227
+ [v1.5.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.4.0...v1.5.0
228
+ [v1.4.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.3.0...v1.4.0
229
+ [v1.3.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.2.0...v1.3.0
230
+ [v1.2.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.1.0...v1.2.0
231
+ [v1.1.0]: https://github.com/sharetribe/flex-sdk-js/compare/v1.0.0...v1.1.0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Sharetribe Flex SDK for JavaScript
2
+
3
+ Use Sharetribe Flex Marketplace API with ease.
4
+
5
+ [![CircleCI](https://circleci.com/gh/sharetribe/flex-sdk-js.svg?style=svg&circle-token=f2209b7cd8300d10f73d359072d7f03f81bff8f4)](https://circleci.com/gh/sharetribe/flex-sdk-js)
6
+
7
+ ## Table of Contents
8
+
9
+ * [What is it?](#what-is-it)
10
+ * [Installation](#installation)
11
+ * [Usage](#usage)
12
+ * [Examples](#examples)
13
+ * [Documentation](#documentation)
14
+ * [License](#license)
15
+
16
+ ## What is it?
17
+
18
+ The SDK is the **easiest** way to interact with Sharetribe Flex
19
+ Marketplace API.
20
+
21
+ It handles **groundwork** such as authentication, renewing
22
+ authentication tokens and serializing and deserializing data to and from
23
+ JavaScript data structures.
24
+
25
+ This lets you to **concentrate on building your marketplace
26
+ front-end** instead of setting up the necessary boilerplate to
27
+ communicate with the API.
28
+
29
+ ## Installation
30
+
31
+ Yarn:
32
+
33
+ ```sh
34
+ yarn add sharetribe-flex-sdk
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```js
40
+ const sharetribeSdk = require('sharetribe-flex-sdk');
41
+
42
+ // Create new SDK instance
43
+ const sdk = sharetribeSdk.createInstance({
44
+ clientId: '<Your Client ID here>'
45
+ });
46
+
47
+ // Query first 5 listings
48
+ sdk.listings
49
+ .query({ per_page: 5 })
50
+ .then(res => {
51
+ // Print listing titles
52
+ res.data.data.forEach(listing => {
53
+ console.log(`Listing: ${listing.attributes.title}`)
54
+ });
55
+ })
56
+ .catch(res => {
57
+ // An error occurred
58
+ console.log(`Request failed with status: ${res.status} ${res.statusText}`);
59
+ });
60
+ ```
61
+
62
+ ## Examples
63
+
64
+ See [examples/](https://github.com/sharetribe/flex-sdk-js/tree/master/examples/) directory in Github repository.
65
+
66
+ ## Documentation
67
+
68
+ [Documentation can be found here](https://sharetribe.github.io/flex-sdk-js/).
69
+
70
+ ## Changelog
71
+
72
+ See [CHANGELOG.md](https://github.com/sharetribe/flex-sdk-js/tree/master/CHANGELOG.md).
73
+
74
+ ## License
75
+
76
+ Distributed under [The Apache License, Version 2.0](https://github.com/sharetribe/flex-sdk-js/tree/master/LICENSE)