sk_api_schema 0.3.4 → 0.4.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.
data/CHANGELOG.rdoc CHANGED
@@ -3,6 +3,7 @@
3
3
  A more detailed view of the changes can be found in the {commit messages}[https://github.com/salesking/sk_api_schema/commits/]
4
4
 
5
5
  2012-06
6
+ * add payments link to invoice, credit_note
6
7
  * add due_date and due_days to order
7
8
  * Deprecate payment.method in favour of payment.payment_method bcs 'method' is a keyword in programming
8
9
  * test with travis-ci.org
data/README.rdoc CHANGED
@@ -1,14 +1,15 @@
1
1
  = SalesKing API Schema
2
2
 
3
- Our API is described with JSON Schema's (http://json-schema.org), describing our objects(resources) in a readable JSON format:
3
+ {<img src="https://secure.travis-ci.org/salesking/sk_api_schema.png?branch=master" alt="Build Status" />}[http://travis-ci.org/salesking/sk_api_schema]
4
+
5
+ Our API (objects,resources) is described with JSON Schema (http://json-schema.org).
6
+ Each Object has its own description, with those top-level keys:
4
7
 
5
8
  {
6
- "title": "client",
7
- "properties": { ...},
8
- "links": [ .. ]
9
+ "title": "client", // object type
10
+ "properties": { .. }, // field descriptions
11
+ "links": [ .. ] // CRUD actions, relationships to other resources
9
12
  }
10
- The properties-section defines the fields. CRUD actions and
11
- relationships with other resources are found in the link-section.
12
13
 
13
14
  Look into the /json/ folder for the resources schema-files - https://github.com/salesking/sk_api_schema/tree/master/json/v1.0
14
15
 
@@ -24,38 +25,6 @@ Other languages should take advantage of the raw json files.
24
25
  * {API Intro}[http://dev.blog.salesking.eu/api/]
25
26
  * {Ruby SDK - API Client}[https://github.com/salesking/sk_sdk]
26
27
 
27
- == Versioning
28
-
29
- The main API-version is kept in the folder-name and as long as there are no major
30
- changes(breaking backwards compatibility), the version number will remain.
31
-
32
- You can see the current schema at:
33
- my.salesking.eu/api/schema
34
- my.salesking.eu/api/clients/schema
35
-
36
- The schema main version(NOT the gem version) can be set with the "v" url parameter
37
- in any call, but is pretty useless as long as we are in v1.0
38
- my.salesking.eu/api/clients?v='1.0'
39
-
40
- The gem has its own version number. A new gem version indicates a change, but
41
- we first try it on our staging environment before any live instances are
42
- updated and the schema becomes public available. The gem is used by SalesKing
43
- to deliver it's data BUT changes might not be directly reflected as stated.
44
- To see the current gem version use:
45
-
46
- my.salesking.eu/api/schema?gem_version=1
47
-
48
- == Save the planet
49
-
50
- By default the API returns an object with all available properties(fields). You
51
- can limit those by passing comma-separated string(or array) in the fields
52
- parameter:
53
- my.salesking.eu/api/clients?fields=id,organisation
54
-
55
- my.salesking.eu/api/clients?fields[]=id&fields[]=organisation
56
-
57
- Please try to only request the fields you really need, to save computing power!
58
-
59
28
  == Object Basic's
60
29
 
61
30
  Primary object types in SK are:
@@ -99,15 +68,86 @@ of each schema.
99
68
  # all invoices of a client
100
69
  /clients/:id/invoices
101
70
 
71
+ == Field types & formats
72
+
73
+ Most of the fields are of type 'string'. Their format(espacially date fields)
74
+ is casted on our side. We try to go with the {formats}[http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23] and {types}[http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1] defined by JSON-Schema
75
+
76
+ All text MUST be UTF-8 encoded.
77
+
78
+ Some example fields:
79
+
80
+ "title":{
81
+ "description": " Cut-off after 255 Characters",
82
+ "type":"string",
83
+ "maxLength": 255
84
+ },
85
+ "notes_before":{
86
+ "description": "Long Text is a custom format: see notes below",
87
+ "type":"string"
88
+ "format":"text"
89
+ },
90
+ "net_total":{
91
+ "description": "Number with 2 decimals places",
92
+ "readonly":true,
93
+ "type":"number"
94
+ },
95
+ "status":{
96
+ "description": "Allowed values are in enum list",
97
+ "default":"draft",
98
+ "enum":["draft","open","closed","rejected","billed" ],
99
+ "type":"string"
100
+ },
101
+ "created_at":{
102
+ "description": "Date time ISO 8601 format: YYYY-MM-DDThh:mm:ssZ",
103
+ "format":"date-time",
104
+ "readonly":true,
105
+ "type":"string"
106
+ },
107
+
108
+ *Text-Format* length varies, between ~16,000 to 65.535, with the occurence of non-ASCII Characters {see this post on stackoverflow}[http://stackoverflow.com/questions/4420164/how-much-utf-8-text-fits-in-a-mysql-text-field]
109
+
110
+ == Versioning
111
+
112
+ The main API-version is kept in the folder-name and as long as there are no major
113
+ changes(breaking backwards compatibility), the version number will remain.
114
+
115
+ You can see the current schema at:
116
+ my.salesking.eu/api/schema
117
+ my.salesking.eu/api/clients/schema
118
+
119
+ The schema main version(NOT the gem version) can be set with the "v" url parameter
120
+ in any call, but is pretty useless as long as we are in v1.0
121
+ my.salesking.eu/api/clients?v='1.0'
122
+
123
+ The gem has its own version number. A new gem version indicates a change, but
124
+ we first try it on our staging environment before any live instances are
125
+ updated and the schema becomes public available. The gem is used by SalesKing
126
+ to deliver it's data BUT changes might not be directly reflected as stated.
127
+ To see the current gem version use:
128
+
129
+ my.salesking.eu/api/schema?gem_version=1
130
+
131
+ == Save the planet
132
+
133
+ By default the API returns an object with all available properties(fields). You
134
+ can limit those by passing comma-separated string(or array) in the fields
135
+ parameter:
136
+ my.salesking.eu/api/clients?fields=id,organisation
137
+
138
+ my.salesking.eu/api/clients?fields[]=id&fields[]=organisation
139
+
140
+ Please try to only request the fields you really need, to save computing power!
141
+
142
+
102
143
  == Install
103
144
 
104
145
  gem install sk_api_schema
105
146
 
106
147
  == Test
107
148
 
108
- {<img src="https://secure.travis-ci.org/salesking/sk_api_schema.png?branch=master" alt="Build Status" />}[http://travis-ci.org/salesking/sk_api_schema]
109
-
110
- Install required gems with bundler and go for it:
149
+ Tested with {travis-ci}[http://travis-ci.org/salesking/sk_api_schema], but of
150
+ course you can run them too. Install required gems with bundler and go for it:
111
151
  # git clone
112
152
  # cd into sk_api_schema dir
113
153
  bundle install
@@ -1,79 +1,81 @@
1
1
  { "type":"object",
2
2
  "title": "address",
3
3
  "description":"An address in SK is maintained within it's parent object(client, company). The first address(default_address) is used inside the address field of new documents. With multiple addresses sorting(first) is done by date, newest first. So if you add a new adddress it will be the new default one. See order and type property for details about ordering and accessing parcel work or home addresses.",
4
- "properties": {
5
- "id": {
6
- "description": "uuid of the address.",
4
+ "properties":{
5
+ "id":{
6
+ "description":"Unique identifier - UUID",
7
7
  "identity":true,
8
8
  "readonly":true,
9
- "type":"string"
9
+ "type":"string",
10
+ "maxLength": 22,
11
+ "minLength":22
10
12
  },
11
- "city": {
13
+ "city":{
12
14
  "description": "City for the address. Must at least be present for an address.",
13
15
  "required":true,
14
16
  "type":"string",
15
17
  "maxLength": 100
16
18
  },
17
- "address1": {
19
+ "address1":{
18
20
  "description": "Should contain the street or otherwise primary address information.",
19
21
  "type":"string",
20
22
  "maxLength": 100
21
23
  },
22
- "address2": {
24
+ "address2":{
23
25
  "description": "Additional address information, like floor number",
24
26
  "type":"string",
25
27
  "maxLength": 100
26
28
  },
27
- "pobox": {
29
+ "pobox":{
28
30
  "description": "Post office box number",
29
31
  "type":"string",
30
32
  "maxLength": 10
31
33
  },
32
- "zip": {
34
+ "zip":{
33
35
  "description": "Zip number of the city. Length must be between 4..10",
34
36
  "type":"string",
35
37
  "maxLength": 10
36
38
  },
37
- "state": {
39
+ "state":{
38
40
  "description": "Country state of address",
39
41
  "type":"string",
40
42
  "maxLength": 100
41
43
  },
42
- "country": {
44
+ "country":{
43
45
  "description": "Country of the address.",
44
46
  "type":"string",
45
47
  "maxLength": 100
46
48
  },
47
- "created_at": {
49
+ "created_at":{
48
50
  "description": "Date the object was created in SK. Never changes afterwards",
49
51
  "format":"date-time",
50
52
  "readonly":true,
51
53
  "type":"string"
52
54
  },
53
- "updated_at": {
55
+ "updated_at":{
54
56
  "description": "Date the object was edited in SK.",
55
57
  "format":"date-time",
56
58
  "readonly":true,
57
59
  "type":"string"
58
60
  },
59
- "address_type": {
61
+ "address_type":{
60
62
  "description": "Type of the address, as seen by vCard definition. There can only be one type. Inside of SK you can use placeholders like client.parcel_address.city to access the first parcel adr(Same for work_ / home_). <br/>Besides the placeholder default_address, always returns the first address found. Sorting is done by the order(if set) else by date, newest first.",
61
63
  "enum":["work","home", "parcel"],
62
64
  "type":"string"
63
65
  },
64
- "order": {
66
+ "order":{
65
67
  "description": "Addresses are normally sorted by date, newest first. If you need to strongly rely on their sorting e.g. default_address (always first) or have multiple addresses of one type(3 parcel), use this field for all adrs. <br/>Single adrs are used in placeholders like: addresses.2.city, returning the second adr found(not necessarily one with order=2).",
66
68
  "type":"integer"
67
69
  },
68
- "lat": {
69
- "description": "Geolocation latitude",
70
- "type":"string"
70
+ "lat":{
71
+ "description": "Geo-Location latitude",
72
+ "type":"number"
71
73
  },
72
- "long": {
73
- "description": "Geolocation longitude",
74
- "type":"string"
74
+ "long":{
75
+ "description": "Geo-Location longitude",
76
+ "type":"number"
75
77
  },
76
- "_destroy": {
78
+ "_destroy":{
77
79
  "description": "When set an existing address will be deleted. This switch is only used when addresses are passed-in nested inside their parent object(a contact).",
78
80
  "type":"boolean"
79
81
  }
@@ -1,53 +1,60 @@
1
1
  { "type":"object",
2
2
  "title": "attachment",
3
3
  "description":"An file attachment",
4
- "properties": {
5
- "id": {
4
+ "properties":{
5
+ "id":{
6
6
  "description": "uuid of the object.",
7
7
  "identity":true,
8
8
  "readonly":true,
9
- "type":"string"
9
+ "type":"string",
10
+ "maxLength": 22,
11
+ "minLength":22
10
12
  },
11
- "filename": {
13
+ "filename":{
12
14
  "description": "The filename as set when uploaded",
13
15
  "readonly":true,
14
- "type":"string"
16
+ "type":"string",
17
+ "maxLength": 255
15
18
  },
16
- "disk_filename": {
19
+ "disk_filename":{
17
20
  "description": "Unique filename set by SK",
18
21
  "readonly":true,
19
- "type":"string"
22
+ "type":"string",
23
+ "maxLength": 255
20
24
  },
21
- "url": {
25
+ "url":{
22
26
  "description": "File download url. Unique and valid for 15 minutes, public accessible.",
23
27
  "readonly":true,
24
- "type":"string"
28
+ "type":"string",
29
+ "format": "uri"
25
30
  },
26
- "related_object_type": {
31
+ "related_object_type":{
27
32
  "description": "Object type of the attachment parent. Is the camelcased base class name: Document for invoice, credit_note,.., Contact for client",
28
33
  "required":true,
29
34
  "type":"string"
30
35
  },
31
- "related_object_id": {
36
+ "related_object_id":{
32
37
  "description": "uuid of the attachment parent object.",
33
38
  "required":true,
34
- "type":"string"
39
+ "type":"string",
40
+ "maxLength": 22,
41
+ "minLength":22
35
42
  },
36
- "content_type": {
43
+ "content_type":{
37
44
  "description": "Auto detected on upload. Might not always reflect the real content type",
38
45
  "readonly":true,
39
46
  "type":"string"
40
47
  },
41
- "size": {
48
+ "size":{
42
49
  "description": "Filesize in kb. Auto detected on upload.",
43
50
  "readonly":true,
44
51
  "type":"integer"
45
52
  },
46
- "is_signed": {
53
+ "is_signed":{
47
54
  "description": "True if the file(pdf) has been digitally signed.",
48
55
  "type":"boolean"
49
56
  },
50
- "created_at": {
57
+ "created_at":{
51
58
  "description": "Date the object was created in SK. Never changes afterwards",
52
59
  "format":"date-time",
53
60
  "readonly":true,
@@ -55,7 +62,9 @@
55
62
  },
56
63
  "team_id":{
57
64
  "description": "A team uuid. If set only the team and its parent teams can see the record.",
58
- "type":"string"
65
+ "type":"string",
66
+ "maxLength": 22,
67
+ "minLength":22
59
68
  }
60
69
 
61
70
  },
@@ -1,29 +1,36 @@
1
1
  {"type":"object",
2
2
  "title": "auth_permission",
3
3
  "description": "A Permission authorises someone to execute actions(grants privileges) in the scope of a context. The context is a resource f.ex: clients, and the privileges a group of actions like: index, show, edit, update. A permission to read invoices has the context: invoices and as privileges: index,show.",
4
- "properties": {
5
- "id": {
4
+ "properties":{
5
+ "id":{
6
+ "description":"Unique identifier - UUID",
6
7
  "identity":true,
7
8
  "readonly":true,
8
- "type":"string"
9
+ "type":"string",
10
+ "maxLength": 22,
11
+ "minLength":22
9
12
  },
10
- "full_name": {
13
+ "full_name":{
11
14
  "description": "Context_name and name localized: API Clients read - API Kunden anzeigen",
12
- "type":"string"
15
+ "type":"string",
16
+ "maxLength": 255
13
17
  },
14
- "name": {
18
+ "name":{
15
19
  "description": "Name for the permission. Since a permission groups multiple privileges the name reflects what someone is allowed to do: read, update, delete. With 'read' granting acccess to the 'index' and 'show' actions of a resource.",
16
- "type":"string"
20
+ "type":"string",
21
+ "maxLength": 255
17
22
  },
18
23
  "context_name":{
19
- "description": "The context for the permission, beeing a resource: clients, emails",
24
+ "description": "The context for the permission, being a resource: clients, emails",
20
25
  "readonly":true,
21
- "type":"string"
26
+ "type":"string",
27
+ "maxLength": 255
22
28
  },
23
- "privilege_list": {
29
+ "privilege_list":{
24
30
  "description": "A permission has many privileges which define the actions someone can execute. Such actions are resource methods like index, update, edit, show",
25
31
  "type":"string",
26
- "readonly":true
32
+ "readonly":true,
33
+ "maxLength": 255
27
34
  }
28
35
  },
29
36
 
@@ -1,88 +1,91 @@
1
1
  {"type":"object",
2
2
  "title": "client",
3
3
  "description": "A client as seen by SalesKing",
4
- "properties": {
5
- "id": {
4
+ "properties":{
5
+ "id":{
6
+ "description":"Unique identifier - UUID",
6
7
  "identity":true,
7
8
  "readonly":true,
8
- "type":"string"
9
+ "type":"string",
10
+ "maxLength": 22,
11
+ "minLength":22
9
12
  },
10
- "number": {
13
+ "number":{
11
14
  "description": "Unique number, auto-created by SK for new client without number.",
12
15
  "type":"string",
13
16
  "maxLength": 50
14
17
  },
15
- "organisation": {
18
+ "organisation":{
16
19
  "description": "Name of a company. This or lastname must be present",
17
20
  "required" : true,
18
21
  "type":"string",
19
22
  "maxLength": 100
20
23
  },
21
- "last_name": {
24
+ "last_name":{
22
25
  "description": "Last name of a person. At least this or the organisation field must be filled for new records",
23
26
  "type":"string",
24
27
  "maxLength": 50
25
28
  },
26
- "first_name": {
29
+ "first_name":{
27
30
  "description": "First name of a person.",
28
31
  "type":"string",
29
32
  "maxLength": 50
30
33
  },
31
- "gender": {
34
+ "gender":{
32
35
  "description": "Can be empty for a company. Is used in salutation",
33
36
  "enum":["male", "female"],
34
37
  "type":"string"
35
38
  },
36
- "notes": {
39
+ "notes":{
37
40
  "description": "Notes for a contact. For day to day information you should use comments instead.",
38
41
  "type":"string",
39
- "maxLength": 65000
42
+ "format": "text"
40
43
  },
41
- "position": {
44
+ "position":{
42
45
  "description": "Position of a person in a company.",
43
46
  "type":"string",
44
47
  "maxLength": 50
45
48
  },
46
- "title": {
49
+ "title":{
47
50
  "description": "Academical title of a person e.g. Dr., Prof",
48
51
  "type":"string",
49
52
  "maxLength": 50
50
53
  },
51
- "tax_number": {
54
+ "tax_number":{
52
55
  "description": "Tax number, normally applies to a private person",
53
56
  "type":"string",
54
57
  "maxLength": 30
55
58
  },
56
- "vat_number": {
59
+ "vat_number":{
57
60
  "description": "VAT number, for a company or person paying value added taxes.",
58
61
  "type":"string",
59
62
  "maxLength": 30
60
63
  },
61
- "email": {
64
+ "email":{
62
65
  "description": "Email address of the contact.",
63
66
  "type":"string",
64
67
  "maxLength": 100
65
68
  },
66
- "url": {
69
+ "url":{
67
70
  "description": "An url associated with the person, e.g its company website.",
68
71
  "type":"string",
69
72
  "maxLength": 255
70
73
  },
71
- "birthday": {
74
+ "birthday":{
72
75
  "format":"date",
73
76
  "type":"string"
74
77
  },
75
- "tag_list": {
76
- "description": "Space separated list of tags.",
78
+ "tag_list":{
79
+ "description": "Space separated list of tags. Are split and saved as Tag objects on create, update.",
77
80
  "type":"string"
78
81
  },
79
- "created_at": {
82
+ "created_at":{
80
83
  "description": "Date the record was created in SK. Never changes afterwards.",
81
84
  "format":"date-time",
82
85
  "readonly":true,
83
86
  "type":"string"
84
87
  },
85
- "updated_at": {
88
+ "updated_at":{
86
89
  "description": "Last date when the record was edited.",
87
90
  "format":"date-time",
88
91
  "readonly":true,
@@ -98,81 +101,83 @@
98
101
  "enum":["cash","bank_transfer","credit_card","paypal","direct_debit","cheque", "moneybookers", "premium_sms"],
99
102
  "type":"string"
100
103
  },
101
- "bank_name": {
104
+ "bank_name":{
102
105
  "description": "Bank name",
103
106
  "type":"string",
104
107
  "maxLength": 70
105
108
  },
106
- "bank_number": {
109
+ "bank_number":{
107
110
  "description": "Bank number",
108
111
  "type":"string",
109
112
  "maxLength": 35
110
113
  },
111
- "bank_account_number": {
114
+ "bank_account_number":{
112
115
  "description": "Bank account number.",
113
116
  "type":"string",
114
117
  "maxLength": 35
115
118
  },
116
- "bank_iban": {
119
+ "bank_iban":{
117
120
  "description": "IBAN Number of the bank account. Is validated",
118
121
  "type":"string",
119
122
  "maxLength": 35
120
123
  },
121
- "bank_swift": {
124
+ "bank_swift":{
122
125
  "description": "SWIFT BIC- Bank Identifier Code",
123
126
  "type":"string",
124
127
  "maxLength": 11
125
128
  },
126
- "bank_owner": {
129
+ "bank_owner":{
127
130
  "description": "Bank account owner",
128
131
  "type":"string",
129
132
  "maxLength": 70
130
133
  },
131
- "phone_fax": {
134
+ "phone_fax":{
132
135
  "description": "Fax number",
133
136
  "type":"string",
134
137
  "maxLength": 30
135
138
  },
136
- "phone_office": {
139
+ "phone_office":{
137
140
  "description": "Office phone number",
138
141
  "type":"string",
139
142
  "maxLength": 30
140
143
  },
141
- "phone_home": {
144
+ "phone_home":{
142
145
  "description": "Private phone number",
143
146
  "type":"string",
144
147
  "maxLength": 30
145
148
  },
146
- "phone_mobile": {
149
+ "phone_mobile":{
147
150
  "description": "Mobile phone number",
148
151
  "type":"string",
149
152
  "maxLength": 30
150
153
  },
151
- "lock_version": {
154
+ "lock_version":{
152
155
  "description": "Increased on every edit, so SK can detect/prevent a concurrent edit by another user. First save wins.",
153
156
  "type":"integer"
154
157
  },
155
- "cash_discount": {
158
+ "cash_discount":{
156
159
  "description": "Default cash discount for new invoices.",
157
160
  "type":"number"
158
161
  },
159
- "due_days": {
162
+ "due_days":{
160
163
  "description": "Default due days for new invoices.",
161
164
  "type":"integer"
162
165
  },
163
- "address_field": {
166
+ "address_field":{
164
167
  "description": "Returns the address field used on new docs. Consist of Organisation name and default(first) address",
165
168
  "readonly":true,
166
169
  "type":"string"
167
170
  },
168
- "addresses": {
171
+ "addresses":{
169
172
  "description": "A client can have many addresses, sorted by date descending(new first). Default address is the most recent one.",
170
173
  "type":"array",
171
174
  "properties" : {"$ref":"./address.json#properties"}
172
175
  },
173
176
  "team_id":{
174
177
  "description": "A team uuid. If set only the team and its parent teams can see the record.",
175
- "type":"string"
178
+ "type":"string",
179
+ "maxLength": 22,
180
+ "minLength":22
176
181
  }
177
182
  },
178
183
  "links":[