Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

[SW-502] Fixed SDK, added a working schema.json from vim-sw PHP SDK #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mborodov
Copy link

@mborodov mborodov commented Nov 3, 2022

No description provided.

@@ -10,15 +10,15 @@ export default class Api {
this.url = url;
this.client = createClient(url, token, version)
this.version = version;
this.schema = require('./data/schema.json')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we load the schematic from the local file


this.EntityDefinition = EntityDefinition;

Object.keys(schema.data).forEach((entityName) => {
this.EntityDefinition.add(entityName, schema.data[entityName]);
Object.keys(this.schema).forEach((entityName) => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small refactor. data subkey is not exist in the new schema file.

@@ -39,7 +39,7 @@ export default class Api {

return new Repository(
route,
definition.entity,
entityName,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously definition.entity returned null. Changed to another variable.

@@ -3,7 +3,7 @@ import axios from 'axios';

export function createClient(url, token, version) {
const client = axios.create({
baseURL: `${url}/api/v${version}`
baseURL: `${url}/api`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed version from URL

@@ -25,7 +25,7 @@ export default class EntityDefinition {
*/
getPrimaryKeyFields() {
return this.filterProperties((property) => {
return property.flags.primary_key === true;
return property.flags.primary === true;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now primary field called 'primary' in the new schema.json

@@ -462,8 +462,7 @@ export default class Repository {
let headers = {
Accept: 'application/vnd.api+json',
Authorization: `Bearer ${context.authToken.access}`,
'Content-Type': 'application/json',
'sw-api-compatibility': compatibility
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, otherwise there was a cors error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant