Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 95ff45b

Browse files
authored
Merge release-v0.1.2 into master
2 parents a112ca8 + 1871b77 commit 95ff45b

File tree

10 files changed

+6709
-2187
lines changed

10 files changed

+6709
-2187
lines changed

.babelrc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
2-
"presets": [
3-
[
4-
"es2015",
5-
{
6-
"modules": false
7-
}
8-
],
9-
"stage-0"
10-
],
11-
"plugins": ["babel-plugin-transform-es2015-modules-commonjs"]
12-
}
2+
"env": {
3+
"production": {
4+
"presets": [
5+
["env", {"modules": false}]
6+
],
7+
"plugins": [
8+
"external-helpers"
9+
]
10+
},
11+
"test": {
12+
"presets": ["env"]
13+
}
14+
}
15+
}

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Description
2+
3+
Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change.
4+
5+
<!-- If this PR fixes an issue, please specify issue #. -->
6+
7+
## Type of change
8+
9+
- [ ] Bug fix (non-breaking change which fixes an issue)
10+
- [ ] New feature (non-breaking change which adds functionality)
11+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
12+
- [ ] Documentation update
13+
14+
## Changes
15+
16+
- (change1)
17+
18+
# How to test this PR?
19+
20+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
21+
22+
# Checklist:
23+
24+
- [ ] My code follows the style guidelines of this project (`npm run lint`)
25+
- [ ] I have performed a self-review of my own code
26+
- [ ] I have commented my code, particularly in hard-to-understand areas
27+
- [ ] I have made corresponding changes to the documentation (`README.md` and `CHANGELOG.md`)
28+
- [ ] I have added tests that prove my fix is effective or that my feature works
29+
- [ ] New and existing unit tests pass locally with my changes (`npm test`)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.DS_Store
22
*.tgz
33

4+
dist/
5+
es/
46
lib/
57
tmp/
68
node_modules

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.1.2 (April 3, 2018)
2+
- Update npm package to ship with three builds: `UMD`, `CommonJS` and `ES2015`
3+
14
## v0.1.1 (November 7, 2017)
25
- Update Rollup output format to 'es'
36

README.md

Lines changed: 111 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,21 @@ _(___ _(___/_/_/__/_/_/__/_(___ _/_____(___ _(___ _(___ _/___(___/_(___(__(___/_
1515

1616
[![CircleCI](https://circleci.com/gh/mobify/commercecloud-ocapi-client.svg?style=svg)](https://circleci.com/gh/mobify/commercecloud-ocapi-client)
1717

18-
## Introduction
18+
## 🙌 Introduction
1919

20-
ShopApi - ES6 JavaScript client for Salesforce Commerce Cloud OCAPI Shop API.
20+
Salesforce Commerce Cloud Open Commerce API (OCAPI) for Node and browsers.
2121

2222
- API version: 17.8
2323

24-
## Installation
24+
### Installation
2525

26-
### For [Node.js](https://nodejs.org/)
27-
28-
#### npm
29-
30-
To publish the library as a [npm](https://www.npmjs.com/),
31-
please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).
32-
33-
Then install it via:
26+
This library is distributed on npm, in order to add it as a dependency, run the following command:
3427

3528
```shell
3629
npm install commercecloud-ocapi-client --save
3730
```
3831

39-
#### git
40-
#
41-
If the library is hosted at a git repository, e.g.
42-
https://github.com/GIT_USER_ID/GIT_REPO_ID
43-
then install it via:
44-
45-
```shell
46-
npm install GIT_USER_ID/GIT_REPO_ID --save
47-
```
48-
49-
### For browser
50-
51-
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
52-
the above steps with Node.js and installing browserify with `npm install -g browserify`,
53-
perform the following (assuming *main.js* is your entry file):
54-
55-
```shell
56-
browserify main.js > bundle.js
57-
```
58-
59-
Then include *bundle.js* in the HTML pages.
60-
61-
### Webpack Configuration
32+
### 🔦 Webpack Configuration
6233

6334
Using Webpack you may encounter the following error: "Module not found: Error:
6435
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
@@ -76,53 +47,135 @@ module: {
7647
}
7748
```
7849

79-
## Getting Started
50+
## 👨🏻‍💻 Getting Started
51+
52+
### 💡 Usage
8053

8154
Please follow the [installation](#installation) instruction and execute the following JS code:
8255

8356
```javascript
8457
import ShopApi from 'commercecloud-ocapi-client'
8558

86-
ShopApi.ApiClient.instance = new ShopApi.ApiClient({
87-
clientUsername: 'YOUR USERNAME', // Configure HTTP basic authorization: customers_auth
88-
clientPassword: 'YOUR PASSWORD', // Configure HTTP basic authorization: customers_auth
89-
oAuthAccessToken: '' // Configure OAuth2 access token for authorization: oauth2_application
90-
})
91-
92-
const api = new ShopApi.BasketsApi()
59+
ShopApi.ApiClient.instance = new ShopApi.ApiClient()
9360

94-
const basketId = "basketId_example" // {String} the id of the basket to be retrieved
61+
const api = new ShopApi.CategoriesApi()
9562

96-
api.deleteBasketsByID(basketId)
63+
api.getCategoriesByIDs(['mens', 'newarrivals'])
9764
.then(() {
9865
console.log('API called successfully.')
9966
})
10067
.catch((fault) => {
10168
console.error(fault)
10269
})
70+
```
71+
72+
73+
### 🔌 Configuration
74+
75+
The API client accepts an configuration object, example:
76+
77+
```js
78+
import ShopApi from 'commercecloud-ocapi-client'
79+
80+
const config = {
81+
basePath: 'https://localhost/s/siteId/dw/shop/v17_8',
82+
defaultHeaders: {}, // HTTP header for all requests
83+
timeout: 60000, // Request timeout in milliseconds
84+
cache: true, // If set to false an additional timestamp parameter is added to all API GET calls to prevent browser caching
85+
enableCookies: false, //If set to true, the client will save the cookies from each server response, and return them in the next request.
86+
}
10387

88+
ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)
10489
```
10590

106-
## Documentation for API Endpoints
91+
10792

108-
- [API Docs](https://mobify.github.io/commercecloud-ocapi-client/)
93+
### 🔐 Authorization
94+
95+
To access secure end points, you can pass the username, password in the configuration, example:
96+
97+
```js
98+
import ShopApi from 'commercecloud-ocapi-client'
10999

110-
## Documentation for Authorization
100+
const config = {
101+
clientUsername: 'username',
102+
clientPassword: 'password',
103+
}
104+
105+
ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)
106+
```
111107

108+
Or to use oAuth token:
109+
110+
```js
111+
import ShopApi from 'commercecloud-ocapi-client'
112+
113+
const config = {
114+
oauth2AccessToken: 'token'
115+
}
116+
117+
ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)
118+
```
119+
120+
## ✅ Testing
121+
122+
Because Salesforce OCAPI is not publicly available, you need to have a running instance that you can test against. In the test folder, there is a file `config.json` that has the example configuration for your environment. Simply update the file with your instance information
123+
124+
Example:
125+
```json
126+
{
127+
"clientId": "5640cc6b-f5e9-466e-9134-9853e9f9db93",
128+
"baseUrl": "https://localhost/s/siteId/dw/shop/v17_8"
129+
}
130+
```
131+
Then run the following command:
132+
133+
```sh
134+
npm test
135+
```
136+
137+
### ♻️ Continuous Integration
138+
139+
We use Circle CI to protect the `develop` and `master` branch to make sure the builds follows the code style and passes all tests. For every pull request, it is required to pass ALL checks including the following tests:
140+
141+
- Linting: `npm run lint`
142+
- Unit Tests: `npm run test`
143+
144+
## 📦 Build and Deployment
145+
146+
At Mobify, we practice several branching strategies, [Release Deployment](https://github.com/mobify/branching-strategy/blob/master/release-deployment.md) is a strategy for projects where feature gets bundled into a release periodically. `master` contains the code for current version, `develop` has the features that is under development and waiting to be released. For new features and bug fixes, please propose pull requests to merge into `develop`.
147+
148+
This package is distributed on npm, on every release, we run scripts to automatically merge `develop` into `master`, test the build in Circle CI as well as publish the package on NPM.
149+
150+
### Changelog
151+
152+
To understand the change between versions, please read [CHANGELOG.md](./CHANGELOG.md). Note that it is required to have a `# To be released` section filled out if you are planning to make pull requests that include new features or bug fixes.
153+
154+
Example:
155+
```markdown
156+
## To be released
157+
- Update npm package to ship with three builds: `UMD`, `CommonJS` and `ES2015` [#4](https://github.com/mobify/commercecloud-ocapi-client/pull/4)
158+
159+
## v0.1.1 (November 7, 2017)
160+
- Update Rollup output format to 'es'
161+
162+
...
163+
```
164+
165+
166+
## 📖 Documentation
167+
168+
- [API Docs](https://mobify.github.io/commercecloud-ocapi-client/)
112169

113-
### client_id
114170

115-
- **Type**: API key
116-
- **API key parameter name**: x-dw-client-id
117-
- **Location**: HTTP header
171+
## 👥 Owner
118172

119-
### customers_auth
173+
This project is open sourced and actively maintained by [Mobify](https://github.com/mobify).
174+
We will make an effort to support the library, but we reserve the right to make incompatible changes when necessary.
120175

121-
- **Type**: HTTP basic authentication
122176

123-
### oauth2_application
177+
## 🏅 Contributors
124178

125-
- **Type**: OAuth
126-
- **Flow**: application
127-
- **Authorization URL**:
128-
- **Scopes**: N/A
179+
- [@jeremywiebe](https://github.com/jeremywiebe)
180+
- [@bendvc](https://github.com/bendvc)
181+
- [@kevinxh](https://github.com/kevinxh)

0 commit comments

Comments
 (0)