Skip to content

Commit a95cd03

Browse files
committed
[SW-502] Fixed SDK, added a working schema.json from vim-sw PHP SDK
1 parent 60ddf5e commit a95cd03

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ export default class Api {
1010
this.url = url;
1111
this.client = createClient(url, token, version)
1212
this.version = version;
13+
this.schema = require('./data/schema.json')
1314
}
1415

1516
async _initialize() {
16-
let schema = await this.client.get('_info/entity-schema.json');
1717

1818
this.EntityDefinition = EntityDefinition;
1919

20-
Object.keys(schema.data).forEach((entityName) => {
21-
this.EntityDefinition.add(entityName, schema.data[entityName]);
20+
Object.keys(this.schema).forEach((entityName) => {
21+
this.EntityDefinition.add(entityName, this.schema[entityName]);
2222
});
2323

2424
const hydrator = new EntityHydrator(this.EntityDefinition);
@@ -39,7 +39,7 @@ export default class Api {
3939

4040
return new Repository(
4141
route,
42-
definition.entity,
42+
entityName,
4343
this.client,
4444
hydrator,
4545
changesetGenerator,

src/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import axios from 'axios';
33

44
export function createClient(url, token, version) {
55
const client = axios.create({
6-
baseURL: `${url}/api/v${version}`
6+
baseURL: `${url}/api`
77
})
88

99
client.defaultUrl = url;

src/data/entity-definition.data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class EntityDefinition {
2525
*/
2626
getPrimaryKeyFields() {
2727
return this.filterProperties((property) => {
28-
return property.flags.primary_key === true;
28+
return property.flags.primary === true;
2929
});
3030
}
3131

src/data/repository.data.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ export default class Repository {
462462
let headers = {
463463
Accept: 'application/vnd.api+json',
464464
Authorization: `Bearer ${context.authToken.access}`,
465-
'Content-Type': 'application/json',
466-
'sw-api-compatibility': compatibility
465+
'Content-Type': 'application/json'
467466
};
468467

469468
if (context.languageId) {

src/data/schema.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)