Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return call and response #29

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.vs
22 changes: 22 additions & 0 deletions Return Response.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Example of a response to a resellers return to its digital warehouse.

{
clientId: "gleerups.se",
serviceProviderId:"goteborgsregionen.se",

licenses: [{
orderRowId: "64b879b1-1fdc-4a42-ae7c-b4f9b287a2cc",
articleNumber: "9789140123456",
status: "Ok",
reason: "",
licenseKey:"235572d0-a26d-4975-97f4-72e4734ff341",
brokenRules:[]
},{
orderRowId: "64b879b1-1fdc-4a42-ae7c-b4f9b287a2cc",
articleNumber: "9789140123456",
status: "NotOk",
reason: "Returns not allowed after 6 months.",
licenseKey:"61893cba-5572-458b-ba91-53320be8bb44",
brokenRules:["unassigned"]
}]
}
23 changes: 23 additions & 0 deletions Return.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Example of a return from the reseller's customer to the reseller. The license is stored in the reseller's digital warehouse that is provided by the supplier.

{
clientId: "goteborgsregionen.se",
serviceProviderId: "gleerups.se"

account: {
id: "GRAB",
identitySource: "client",
schoolUnitCode: "456781",
organizationNumber: "2120001355",
name: "G�teborgs stad",
rules: ["unassigned", "notUsed"]
},

rows: [{
quantity: null,
licenseKeys: ["235572d0-a26d-4975-97f4-72e4734ff341", "61893cba-5572-458b-ba91-53320be8bb44"],
articleNumber: "9789140123456",
orderRowId: "64b879b1-1fdc-4a42-ae7c-b4f9b287a2cc"
}]

}
140 changes: 140 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ FYI: Some terms have the Swedish name in parenthesis and the file names of the s

**[3. Statistics](#3-statistics)**: A license portal can fetch data from the producers and present the customer with how many licenses that have been acquired and how many that are actually being used. The data includes information on when the licenses were purchased and when they expire.

**[4. Return](#4-return)**: Returns from the reseller's customers to the reseller. The licenses is stored in the reseller's digital warehouse that is provided by the supplier.

Samples files are available via GitHub together with the most up to date information.

# 1. Order
Expand Down Expand Up @@ -437,6 +439,144 @@ Call for getting an update on a certain license on a certain school.

Call for getting licenses and status update for either an entire organisation (Statistik Metod 2 Anrop med organisationsnummer.js) or school unit code (Statistik Metod 2 Anrop med skolenhetskoder.js).

# 4. Return

This call is made when a reseller's customer wants to create a return and the reseller has the ambition to sell the license to another customer. The license is stored in a 'digital warehouse' provided by the supplier.

## Call from webshop

```javascript
{
clientId: "goteborgsregionen.se",
serviceProviderId: "gleerups.se",

account: {
id: "GRAB",
identitySource: "client",
schoolUnitCode: "456781",
organizationNumber: "2120001355",
name: "Göteborgs stad",
rules: ["unassigned", "notUsed"]
},

rows: [{
licenseKeys: ["235572d0-a26d-4975-97f4-72e4734ff341", "61893cba-5572-458b-ba91-53320be8bb44"],
articleNumber: "9789140123456",
orderRowId: "64b879b1-1fdc-4a42-ae7c-b4f9b287a2cc"
}]

}
```

| Property | Type | Mandatory | Description |
| --- | --- | --- | --- |
| clientId | string | x | Webshop id, E.g. goteborgsregionen.se |
| serviceProviderId | string | x | Supplier id, E.g. nok.se |
| account | object | x | Principal organization, commonly a school unit |
| account.id | string | x | Customer ID, e.g. account number |
| account.identitySource | string | x | Type of id. E.g. if it is the account number of the customer it should be set to "client" |
| account.schoolUnitCode | string | | School unit code |
| account.organizationNumber | string | x | Organization number |
| account.name | string | x | Name of the school unit |
| account.rules | array | | Return rules determined by the reseller and verified by the supplier |
| rows | array | x | Rows that is going to be returned. A row represent a whole or a subset of a purchase row. |
| rows.licenseKeys | array | x | Array of licensekeys that is being return. Either licensekeys or quantity has to be specified. |
| rows.articleNumber | string | x | Article number of the product being returned |
| rows.orderRowId | number | x | Row ID, that is used in the purchase call, is used to match return replys with the response|


### Value list for Return - identitySource
| identitySource | Description |
| --- | --- |
| client | Webshop prorietary id |
| EGIL | EGIL-client id |
| Google | Google-id |
| Microsoft | Microsoft-id |

### Value list for Return - rules
| rules | Description |
| --- | --- |
| notAssigned | Return allowed only on licenses that are not assigned |
| notUsed | Return allowed only if the license has not been used |

Choose a reason for hiding this comment

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

Regading the rules:

If more than one rule is sent, does this mean that it is enough for a license to fulfill only one of the rules, or does it mean that all rules must be fulfilled for the license to be returnable (should the rules be combined with AND or OR)?

What does the specific rules actually mean? Is "notUsed" a license that has never been assigned to a user? Can we change the name of "unAssigned" to "notAssigned" if the meaning is that the license currently isn't assigned to a user?

Is there a need for more rules? Maybe we can discuss this at the next meeting, and add more later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great questions! I think it should be AND? But that can be discussed, and also what kind of rules do we need? Would be good to get more feedback from other suppliers as well.

| expired | Return allowed only if the license has not been expired |


## Return reply

The supplier is expected to reply directly. A return row is either a success or not. Partially succeded rows are not allowed, i.e. if any license on a row does not go well, no licenses on that row is not returned even if possible. The reseller can however se the status of each license to determine which one needs to be changed. For instance if there is a rule that says a license must be unassigned, the reseller can help their customer unassigned it and later retry the return.

```javascript
{
clientId:"gleerups.se",
serviceProviderId:"goteborgsregionen.se",

rows: [{
licenseKeys: [
{
key: "61893cba-5572-458b-ba91-53320be8bb44",
status: "Ok"
}
{
key: "235572d0-a26d-4975-97f4-72e4734ff341",
status: "rulesBroken",
brokenRules: [
{
rule: "notAssigned",
userId: [email protected]
},
{
rule: "notUsed",
date: "YYYY-MM-DD TT:MM:SS"
},
{
rule: "expired",
date: "YYYY-MM-DD TT:MM:SS"
}]
},
"27f03df5-5495-4a3b-a775-1ac1578ac368" : {
status: "NotOk",
reason: "Some other reason",
},
],
articleNumber: "9789140123456",
orderRowId: "64b879b1-1fdc-4a42-ae7c-b4f9b287a2cc"
}]
}

```

| Property | Type | Mandatory | Description |
| --- | --- | --- | --- |
| clientId | string | x | Webshop id, e.g. goteborgsregionen.se |
| serviceProviderId | string | x | Supplier id, t.ex. nok.se |
| rows | array | x | Answer with the same rows and licenses as the call |
| rows.orderRowId | string | x | Row ID, used to match return replys with the response |
| rows.articleNumber | string | x | Article number of the product being returned |
| rows.licenseKeys | array | x | Array of the license keys that were in the call|
| rows.licenseKeys.key | string | x | License key |
| rows.licenseKeys.status | string | x | error, ok, rulesBroken. See value list below |
| rows.licenseKeys.reason | string | | Used with status NotOk |
| rows.licenseKeys.brokenRules | array | | Array with objects of broken rules and can contain more info depending on the rule broken. Can be the same or a subset of the rules sent in the return call. See value list above |
| rows.licenseKeys.rule | string | x | The broken rule |
| rows.licenseKeys.userId | string | x | Is mandatory for rule 'notAssigned', id for the user using the key |
| rows.licenseKeys.date | date | x | Is mandatory for rule 'notUsed', start date of using the article. Is also mandatory for expired, date of when the article was expired.|




### Value list return reply
| Status | Description |
| --- | --- |
| NotOk | The supplier does not accept this return, description of the reason is provided in reason. |
| Ok | This license is returned. |
| RulesBroken | The license is NOT returned because there are one or more rules broken. |

## Sample files

### Return.js
Sample file shows a return that has two licenseKeys that the customer wants to return. The supplier validates the return by its own rules and those provided by the reseller.
Return reply (Return Response.js) shows that one license in Ok to return, but is not because the second row has two validation errors. One is the reseller rule is broken and the second is a supplier rule i broken.

# Dates

Should be formated according to ISO 8601 (YYYY-MM-DD) “2020-03-30”.
Expand Down