sk_api_schema 0.0.4 → 0.0.5
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/VERSION +1 -1
- data/json/v1.0/credit_note.json +31 -2
- data/json/v1.0/estimate.json +204 -0
- data/json/v1.0/invoice.json +64 -25
- data/json/v1.0/order.json +194 -0
- data/json/v1.0/payment_reminder.json +179 -0
- data/lib/sk_api_schema.rb +91 -53
- data/sk_api_schema.gemspec +23 -22
- data/spec/sk_api_schema_spec.rb +26 -4
- metadata +10 -8
- data/.gitignore +0 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/json/v1.0/credit_note.json
CHANGED
@@ -67,6 +67,10 @@
|
|
67
67
|
"description": "The clients uuid, must be set for a new document. New documents take the clients address field, due days and cash discount if those fields are not set.",
|
68
68
|
"type":"string"
|
69
69
|
},
|
70
|
+
"team_id":{
|
71
|
+
"description": "A team uuid. If set only the team and its parent teams can see the record.",
|
72
|
+
"type":"string"
|
73
|
+
},
|
70
74
|
"line_items":{
|
71
75
|
"description": "Line items for the document",
|
72
76
|
"type":"array",
|
@@ -89,12 +93,37 @@
|
|
89
93
|
"type":"integer"
|
90
94
|
},
|
91
95
|
"price_total":{
|
92
|
-
"description": "
|
96
|
+
"description": "Deprecated use net_total_base_raw",
|
93
97
|
"readonly":true,
|
94
98
|
"type":"number"
|
95
99
|
},
|
96
100
|
"price_tax":{
|
97
|
-
"description": "
|
101
|
+
"description": "Deprecated: use tax_total",
|
102
|
+
"readonly":true,
|
103
|
+
"type":"number"
|
104
|
+
},
|
105
|
+
"gross_total":{
|
106
|
+
"description": "Gross total of all line items, 2 decimals places",
|
107
|
+
"readonly":true,
|
108
|
+
"type":"number"
|
109
|
+
},
|
110
|
+
"tax_total":{
|
111
|
+
"description": "Tax total, 2 decimals places",
|
112
|
+
"readonly":true,
|
113
|
+
"type":"number"
|
114
|
+
},
|
115
|
+
"net_total":{
|
116
|
+
"description": "Net total, 2 decimals places",
|
117
|
+
"readonly":true,
|
118
|
+
"type":"number"
|
119
|
+
},
|
120
|
+
"net_total_base":{
|
121
|
+
"description": "Net total, decimals places as set in precision, default 2",
|
122
|
+
"readonly":true,
|
123
|
+
"type":"number"
|
124
|
+
},
|
125
|
+
"net_total_base_raw":{
|
126
|
+
"description": "Net total, 6 decimal places. Summmed items net_total_base_raw (incl discount)",
|
98
127
|
"readonly":true,
|
99
128
|
"type":"number"
|
100
129
|
}
|
@@ -0,0 +1,204 @@
|
|
1
|
+
{ "type":"object",
|
2
|
+
"title": "estimate",
|
3
|
+
"description": "An estimate",
|
4
|
+
"properties":{
|
5
|
+
"id":{
|
6
|
+
"description": "UUID assigned by SK",
|
7
|
+
"identity":true,
|
8
|
+
"readonly":true,
|
9
|
+
"type":"string"
|
10
|
+
},
|
11
|
+
"number":{
|
12
|
+
"description": "Unique number assigned by SK estimate number schema. Auto-assigned when estimate is opened. Required unless doc status is draft.",
|
13
|
+
"type":"string"
|
14
|
+
},
|
15
|
+
"address_field":{
|
16
|
+
"description": "Receiver address, normally shown in envelope window. Defaults to client address_field if empty and client_id present.",
|
17
|
+
"type":"string"
|
18
|
+
},
|
19
|
+
"date":{
|
20
|
+
"description": "Date the estimate is issued. Automatically set when estimate is opened. Required for non-draft documents.",
|
21
|
+
"format":"date",
|
22
|
+
"type":"string"
|
23
|
+
},
|
24
|
+
"due_days":{
|
25
|
+
"description": "Used to calculate the valid-until date of the estimate. Useless if date and due date are present.",
|
26
|
+
"type":"integer"
|
27
|
+
},
|
28
|
+
"due_date":{
|
29
|
+
"description": "Auto-calculated from date + due days if empty and the estimate is opened.",
|
30
|
+
"format":"date",
|
31
|
+
"type":"string"
|
32
|
+
},
|
33
|
+
"status":{
|
34
|
+
"description": "Defaults to draft for new documents, if empty. For new documents with status 'open', the following fields are set if empty: number(next in number schema), date(today), due date(today unless due_days given). Only drafts can be deleted.",
|
35
|
+
"default":"draft",
|
36
|
+
"enum":["draft","open","closed"],
|
37
|
+
"type":"string"
|
38
|
+
},
|
39
|
+
"title":{
|
40
|
+
"description": "The headline of a document. Use SK placeholders to prevent exessive typing e.g. 'Your estimate [number]'",
|
41
|
+
"type":"string"
|
42
|
+
},
|
43
|
+
"notes_before":{
|
44
|
+
"description": "Notes shown before the line items. Normaly contains salutation and other introductional information. SK placeholders can be used.",
|
45
|
+
"type":"string"
|
46
|
+
},
|
47
|
+
"notes_after":{
|
48
|
+
"description": "Notes shown after the line items. Can contain information about payments, bank account or a thank-you message. SK placeholders can be used.",
|
49
|
+
"type":"string"
|
50
|
+
},
|
51
|
+
"tag_list": {
|
52
|
+
"description": "Space separated list of tags.",
|
53
|
+
"type":"string"
|
54
|
+
},
|
55
|
+
"precision":{
|
56
|
+
"description": "Decimal places for displayed(printed) money values. gross_total and net_total will always be displayed rounded to a precision of 2. When greater 2 use net_total_base(also in line_item) to show the net val with the set precision(3,4).",
|
57
|
+
"type":"number",
|
58
|
+
"enum": [2,3,4],
|
59
|
+
"default":2
|
60
|
+
},
|
61
|
+
"archived_pdf":{
|
62
|
+
"description": "Archived PDF version of the document. Is created when an document is printed and archived. A document can have multiple archived versions. This only returns the most recent one. ",
|
63
|
+
"readonly":true,
|
64
|
+
"type":"object",
|
65
|
+
"properties":{"$ref":"./attachment.json#properties"}
|
66
|
+
},
|
67
|
+
"client":{
|
68
|
+
"description": "The client for the document. New documents cannot create a client, use client_id field to set it.",
|
69
|
+
"readonly":true,
|
70
|
+
"type":"object",
|
71
|
+
"properties":{"$ref":"./client.json#properties"}
|
72
|
+
},
|
73
|
+
"client_id":{
|
74
|
+
"description": "The clients uuid, must be set for a new document. New estimates take the clients address field, due days and cash discount if those fields are not set.",
|
75
|
+
"type":"string",
|
76
|
+
"required":true
|
77
|
+
},
|
78
|
+
"team_id":{
|
79
|
+
"description": "A team uuid. If set only the team and its parent teams can see the record.",
|
80
|
+
"type":"string"
|
81
|
+
},
|
82
|
+
"line_items":{
|
83
|
+
"description": "Line items for the document",
|
84
|
+
"type":"array",
|
85
|
+
"properties":{"$ref":"./address.json#properties"}
|
86
|
+
},
|
87
|
+
"created_at":{
|
88
|
+
"description": "Date the object was created in SK. Never changes afterwards.",
|
89
|
+
"format":"date-time",
|
90
|
+
"readonly":true,
|
91
|
+
"type":"string"
|
92
|
+
},
|
93
|
+
"updated_at":{
|
94
|
+
"description": "Date the object was edited in SK.",
|
95
|
+
"format":"date-time",
|
96
|
+
"readonly":true,
|
97
|
+
"type":"string"
|
98
|
+
},
|
99
|
+
"lock_version":{
|
100
|
+
"description": "Auto-incremented to prevent concurrent updateing. First save wins and increments version.",
|
101
|
+
"optional":true,
|
102
|
+
"type":"integer"
|
103
|
+
},
|
104
|
+
"gross_total":{
|
105
|
+
"description": "Gross total of all line items, 2 decimals places",
|
106
|
+
"readonly":true,
|
107
|
+
"type":"number"
|
108
|
+
},
|
109
|
+
"tax_total":{
|
110
|
+
"description": "Tax total, 2 decimals places",
|
111
|
+
"readonly":true,
|
112
|
+
"type":"number"
|
113
|
+
},
|
114
|
+
"net_total":{
|
115
|
+
"description": "Net total, 2 decimals places",
|
116
|
+
"readonly":true,
|
117
|
+
"type":"number"
|
118
|
+
},
|
119
|
+
"net_total_base":{
|
120
|
+
"description": "Net total, decimals places as set in precision, default 2",
|
121
|
+
"readonly":true,
|
122
|
+
"type":"number"
|
123
|
+
},
|
124
|
+
"net_total_base_raw":{
|
125
|
+
"description": "Net total unrounded, 6 decimal places. Summed items net_total_base_raw (incl discount)",
|
126
|
+
"readonly":true,
|
127
|
+
"type":"number"
|
128
|
+
}
|
129
|
+
},
|
130
|
+
"links":[
|
131
|
+
{ "rel": "self",
|
132
|
+
"href": "estimates/{id}"
|
133
|
+
},
|
134
|
+
{ "rel": "instances",
|
135
|
+
"href": "estimates",
|
136
|
+
"properties" : {
|
137
|
+
"page":{
|
138
|
+
"title" : "Page",
|
139
|
+
"description": "In paginated results set the page to look for",
|
140
|
+
"type":"number"
|
141
|
+
},
|
142
|
+
"filter[q]":{
|
143
|
+
"title" : "Search",
|
144
|
+
"description": "Search in title, number, addressfield",
|
145
|
+
"type":"string"
|
146
|
+
},
|
147
|
+
"filter[tags]":{
|
148
|
+
"title" : "Tags",
|
149
|
+
"description": "Filter by a space delimited list of tags",
|
150
|
+
"type":"string"
|
151
|
+
},
|
152
|
+
"filter[from]":{
|
153
|
+
"title" : "From date",
|
154
|
+
"description": "All objects with a date after the date"
|
155
|
+
},
|
156
|
+
"filter[to]":{
|
157
|
+
"title" : "To date",
|
158
|
+
"description": "All objects with date before the date"
|
159
|
+
},
|
160
|
+
"sort_by":{
|
161
|
+
"title" : "Sort by",
|
162
|
+
"description": "Sort the results by the given field => number",
|
163
|
+
"enum":['title', 'number', 'created_at', 'updated_at', 'client_id', 'price_total', 'price_tax', 'date', 'due_date'],
|
164
|
+
"type": 'string'
|
165
|
+
},
|
166
|
+
"sort":{
|
167
|
+
"title" : "Sort",
|
168
|
+
"enum":["ASC","DESC"],
|
169
|
+
"description": "Sort the results in ASC or DESC"
|
170
|
+
}
|
171
|
+
}
|
172
|
+
},
|
173
|
+
{ "rel": "destroy",
|
174
|
+
"href": "estimates/{id}",
|
175
|
+
"method": "DELETE"
|
176
|
+
},
|
177
|
+
{ "rel": "update",
|
178
|
+
"href": "estimates/{id}",
|
179
|
+
"method": "PUT"
|
180
|
+
},
|
181
|
+
{ "rel": "create",
|
182
|
+
"href": "estimates",
|
183
|
+
"method": "POST"
|
184
|
+
},
|
185
|
+
{ "rel": "attachments",
|
186
|
+
"href": "estimates/{id}/attachments"
|
187
|
+
},
|
188
|
+
{ "rel": "print",
|
189
|
+
"href": "estimates/{id}/print",
|
190
|
+
"method": "POST",
|
191
|
+
"properties" : {
|
192
|
+
"template_id" : {
|
193
|
+
"title" : "PDF template used for printing",
|
194
|
+
"description": "UUID of a pdf template used to print the document. MUST be present",
|
195
|
+
"required":true
|
196
|
+
},
|
197
|
+
"base64" : {
|
198
|
+
"title" : "Return the created pdf base64 encoded",
|
199
|
+
"description": "If set the new pdf is returned inside the attachment JSON within 'base64' key. Leave empty to save traffic."
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
]
|
204
|
+
}
|
data/json/v1.0/invoice.json
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
{ "type":"object",
|
2
2
|
"title": "invoice",
|
3
|
-
"description": "An invoice",
|
4
|
-
|
3
|
+
"description": "An invoice",
|
5
4
|
"properties":{
|
6
5
|
"id":{
|
7
6
|
"description": "UUID assigned by SK",
|
@@ -14,7 +13,7 @@
|
|
14
13
|
"type":"string"
|
15
14
|
},
|
16
15
|
"address_field":{
|
17
|
-
"description": "
|
16
|
+
"description": "Receiver address, normally shown in envelope window. Defaults to client address_field if empty and client_id given.",
|
18
17
|
"type":"string"
|
19
18
|
},
|
20
19
|
"date":{
|
@@ -32,7 +31,7 @@
|
|
32
31
|
"type":"string"
|
33
32
|
},
|
34
33
|
"status":{
|
35
|
-
"description": "Defaults to draft for new documents, if empty. For new documents with status 'open',the following fields are set if empty: number(next in number schema), date(today), due date(today unless due_days given). Only
|
34
|
+
"description": "Defaults to draft for new documents, if empty. For new documents with status 'open',the following fields are set if empty: number(next in number schema), date(today), due date(today unless due_days given). Only drafts can be deleted.",
|
36
35
|
"default":"draft",
|
37
36
|
"enum":["draft","open","closed"],
|
38
37
|
"type":"string"
|
@@ -55,14 +54,14 @@
|
|
55
54
|
"type":"string"
|
56
55
|
},
|
57
56
|
"tag_list": {
|
58
|
-
"description": "Space
|
57
|
+
"description": "Space separated list of tags.",
|
59
58
|
"type":"string"
|
60
59
|
},
|
61
|
-
"
|
62
|
-
"description": "
|
63
|
-
"
|
64
|
-
"
|
65
|
-
"
|
60
|
+
"precision":{
|
61
|
+
"description": "Decimal places for displayed(printed) money values. gross_total and net_total will always be displayed rounded to a precision of 2. When greater 2 use net_total_base(also in line_item) to show the net val with the set precision(3,4).",
|
62
|
+
"type":"number",
|
63
|
+
"enum": [2,3,4],
|
64
|
+
"default":2
|
66
65
|
},
|
67
66
|
"archived_pdf":{
|
68
67
|
"description": "Archived PDF version of the document. Is created when an document is printed and archived. A document can have multiple archived versions. This only returns the most recent one. ",
|
@@ -70,11 +69,21 @@
|
|
70
69
|
"type":"object",
|
71
70
|
"properties":{"$ref":"./attachment.json#properties"}
|
72
71
|
},
|
72
|
+
"client":{
|
73
|
+
"description": "The client for the document. New documents cannot create a client, use client_id field to set it.",
|
74
|
+
"readonly":true,
|
75
|
+
"type":"object",
|
76
|
+
"properties":{"$ref":"./client.json#properties"}
|
77
|
+
},
|
73
78
|
"client_id":{
|
74
79
|
"description": "The clients uuid, must be set for a new document. New invoices take the clients address field, due days and cash discount if those fields are not set.",
|
75
80
|
"type":"string",
|
76
81
|
"required":true
|
77
82
|
},
|
83
|
+
"team_id":{
|
84
|
+
"description": "A team uuid. If set only the team and its parent teams can see the record.",
|
85
|
+
"type":"string"
|
86
|
+
},
|
78
87
|
"line_items":{
|
79
88
|
"description": "Line items for the document",
|
80
89
|
"type":"array",
|
@@ -93,17 +102,42 @@
|
|
93
102
|
"type":"string"
|
94
103
|
},
|
95
104
|
"lock_version":{
|
96
|
-
"description": "Auto-incremented
|
105
|
+
"description": "Auto-incremented to prevent concurrent updateing. First save wins and increments version. ",
|
97
106
|
"optional":true,
|
98
107
|
"type":"integer"
|
99
108
|
},
|
100
109
|
"price_total":{
|
101
|
-
"description": "
|
110
|
+
"description": "Deprecated use net_total_base_raw",
|
102
111
|
"readonly":true,
|
103
112
|
"type":"number"
|
104
113
|
},
|
105
114
|
"price_tax":{
|
106
|
-
"description": "
|
115
|
+
"description": "Deprecated: use tax_total",
|
116
|
+
"readonly":true,
|
117
|
+
"type":"number"
|
118
|
+
},
|
119
|
+
"gross_total":{
|
120
|
+
"description": "Gross total of all line items, 2 decimals places",
|
121
|
+
"readonly":true,
|
122
|
+
"type":"number"
|
123
|
+
},
|
124
|
+
"tax_total":{
|
125
|
+
"description": "Tax total, 2 decimals places",
|
126
|
+
"readonly":true,
|
127
|
+
"type":"number"
|
128
|
+
},
|
129
|
+
"net_total":{
|
130
|
+
"description": "Net total, 2 decimals places",
|
131
|
+
"readonly":true,
|
132
|
+
"type":"number"
|
133
|
+
},
|
134
|
+
"net_total_base":{
|
135
|
+
"description": "Net total, decimals places as set in precision, default 2",
|
136
|
+
"readonly":true,
|
137
|
+
"type":"number"
|
138
|
+
},
|
139
|
+
"net_total_base_raw":{
|
140
|
+
"description": "Net total, 6 decimal places. Summmed items net_total_base_raw (incl discount)",
|
107
141
|
"readonly":true,
|
108
142
|
"type":"number"
|
109
143
|
}
|
@@ -114,19 +148,21 @@
|
|
114
148
|
},
|
115
149
|
{ "rel": "instances",
|
116
150
|
"href": "invoices",
|
117
|
-
// Params /invoices?page=1&sort_by
|
118
151
|
"properties" : {
|
119
|
-
"q":{
|
120
|
-
"title" : "Search",
|
121
|
-
"description": "Search parameter."
|
122
|
-
},
|
123
152
|
"page":{
|
124
153
|
"title" : "Page",
|
125
|
-
"description": "In paginated results set the page to look for"
|
154
|
+
"description": "In paginated results set the page to look for",
|
155
|
+
"type":"number"
|
156
|
+
},
|
157
|
+
"filter[q]":{
|
158
|
+
"title" : "Search",
|
159
|
+
"description": "Search in title, number, addressfield",
|
160
|
+
"type":"string"
|
126
161
|
},
|
127
162
|
"filter[tags]":{
|
128
163
|
"title" : "Tags",
|
129
|
-
"description": "Filter by a space delimited list of tags"
|
164
|
+
"description": "Filter by a space delimited list of tags",
|
165
|
+
"type":"string"
|
130
166
|
},
|
131
167
|
"filter[from]":{
|
132
168
|
"title" : "From date",
|
@@ -138,10 +174,13 @@
|
|
138
174
|
},
|
139
175
|
"sort_by":{
|
140
176
|
"title" : "Sort by",
|
141
|
-
"description": "Sort the results by the given field =>
|
177
|
+
"description": "Sort the results by the given field => number",
|
178
|
+
"enum":['title', 'number', 'created_at', 'updated_at', 'client_id', 'price_total', 'price_tax', 'date', 'due_date'],
|
179
|
+
"type": 'string'
|
142
180
|
},
|
143
181
|
"sort":{
|
144
182
|
"title" : "Sort",
|
183
|
+
"enum":["ASC","DESC"],
|
145
184
|
"description": "Sort the results in ASC or DESC"
|
146
185
|
}
|
147
186
|
}
|
@@ -152,15 +191,15 @@
|
|
152
191
|
},
|
153
192
|
{ "rel": "update",
|
154
193
|
"href": "invoices/{id}",
|
155
|
-
"method": "PUT"
|
156
|
-
"properties" : {
|
157
|
-
"invoice" : {"$ref":"./invoice.json#properties"}
|
158
|
-
}
|
194
|
+
"method": "PUT"
|
159
195
|
},
|
160
196
|
{ "rel": "create",
|
161
197
|
"href": "invoices",
|
162
198
|
"method": "POST"
|
163
199
|
},
|
200
|
+
{ "rel": "attachments",
|
201
|
+
"href": "invoices/{id}/attachments"
|
202
|
+
},
|
164
203
|
{ "rel": "print",
|
165
204
|
"href": "invoices/{id}/print",
|
166
205
|
"method": "POST",
|
@@ -0,0 +1,194 @@
|
|
1
|
+
{ "type":"object",
|
2
|
+
"title": "order",
|
3
|
+
"description": "An order",
|
4
|
+
"properties":{
|
5
|
+
"id":{
|
6
|
+
"description": "UUID assigned by SK",
|
7
|
+
"identity":true,
|
8
|
+
"readonly":true,
|
9
|
+
"type":"string"
|
10
|
+
},
|
11
|
+
"number":{
|
12
|
+
"description": "Unique number assigned by SK order number schema. Auto-assigned when order is opened. Required unless doc status is draft.",
|
13
|
+
"type":"string"
|
14
|
+
},
|
15
|
+
"address_field":{
|
16
|
+
"description": "Receiver address, normally shown in envelope window. Defaults to client address_field if empty and client_id present.",
|
17
|
+
"type":"string"
|
18
|
+
},
|
19
|
+
"date":{
|
20
|
+
"description": "Date the order is issued. Automatically set when order is opened. Required for non-draft documents.",
|
21
|
+
"format":"date",
|
22
|
+
"type":"string"
|
23
|
+
},
|
24
|
+
"status":{
|
25
|
+
"description": "Defaults to draft for new documents, if empty. For new documents with status 'open', the following fields are set if empty: number(next in number schema), date(today). Only drafts can be deleted.",
|
26
|
+
"default":"draft",
|
27
|
+
"enum":["draft","open","closed"],
|
28
|
+
"type":"string"
|
29
|
+
},
|
30
|
+
"title":{
|
31
|
+
"description": "The headline of a document. Use SK placeholders to prevent exessive typing e.g. 'Your order [number]'",
|
32
|
+
"type":"string"
|
33
|
+
},
|
34
|
+
"notes_before":{
|
35
|
+
"description": "Notes shown before the line items. Normaly contains salutation and other introductional information. SK placeholders can be used.",
|
36
|
+
"type":"string"
|
37
|
+
},
|
38
|
+
"notes_after":{
|
39
|
+
"description": "Notes shown after the line items. Can contain information about payments, bank account or a thank-you message. SK placeholders can be used.",
|
40
|
+
"type":"string"
|
41
|
+
},
|
42
|
+
"tag_list": {
|
43
|
+
"description": "Space separated list of tags.",
|
44
|
+
"type":"string"
|
45
|
+
},
|
46
|
+
"precision":{
|
47
|
+
"description": "Decimal places for displayed(printed) money values. gross_total and net_total will always be displayed rounded to a precision of 2. When greater 2 use net_total_base(also in line_item) to show the net val with the set precision(3,4).",
|
48
|
+
"type":"number",
|
49
|
+
"enum": [2,3,4],
|
50
|
+
"default":2
|
51
|
+
},
|
52
|
+
"archived_pdf":{
|
53
|
+
"description": "Archived PDF version of the document. Is created when an document is printed and archived. A document can have multiple archived versions. This only returns the most recent one. ",
|
54
|
+
"readonly":true,
|
55
|
+
"type":"object",
|
56
|
+
"properties":{"$ref":"./attachment.json#properties"}
|
57
|
+
},
|
58
|
+
"client":{
|
59
|
+
"description": "The associated client. New documents cannot create a client, use client_id to set it.",
|
60
|
+
"readonly":true,
|
61
|
+
"type":"object",
|
62
|
+
"properties":{"$ref":"./client.json#properties"}
|
63
|
+
},
|
64
|
+
"client_id":{
|
65
|
+
"description": "The clients uuid, must not be set for a new document. New docuents take the clients address field, due days and cash discount if client is present abd those fields are not set.",
|
66
|
+
"type":"string"
|
67
|
+
},
|
68
|
+
"team_id":{
|
69
|
+
"description": "A team uuid. If set only the team and its parent teams can see the record.",
|
70
|
+
"type":"string"
|
71
|
+
},
|
72
|
+
"line_items":{
|
73
|
+
"description": "Line items for the document",
|
74
|
+
"type":"array",
|
75
|
+
"properties":{"$ref":"./address.json#properties"}
|
76
|
+
},
|
77
|
+
"created_at":{
|
78
|
+
"description": "Date the object was created in SK. Never changes afterwards.",
|
79
|
+
"format":"date-time",
|
80
|
+
"readonly":true,
|
81
|
+
"type":"string"
|
82
|
+
},
|
83
|
+
"updated_at":{
|
84
|
+
"description": "Date the object was edited in SK.",
|
85
|
+
"format":"date-time",
|
86
|
+
"readonly":true,
|
87
|
+
"type":"string"
|
88
|
+
},
|
89
|
+
"lock_version":{
|
90
|
+
"description": "Auto-incremented to prevent concurrent updateing. First save wins and increments version.",
|
91
|
+
"optional":true,
|
92
|
+
"type":"integer"
|
93
|
+
},
|
94
|
+
"gross_total":{
|
95
|
+
"description": "Gross total of all line items, 2 decimals places",
|
96
|
+
"readonly":true,
|
97
|
+
"type":"number"
|
98
|
+
},
|
99
|
+
"tax_total":{
|
100
|
+
"description": "Tax total, 2 decimals places",
|
101
|
+
"readonly":true,
|
102
|
+
"type":"number"
|
103
|
+
},
|
104
|
+
"net_total":{
|
105
|
+
"description": "Net total, 2 decimals places",
|
106
|
+
"readonly":true,
|
107
|
+
"type":"number"
|
108
|
+
},
|
109
|
+
"net_total_base":{
|
110
|
+
"description": "Net total, decimals places as set in precision, default 2",
|
111
|
+
"readonly":true,
|
112
|
+
"type":"number"
|
113
|
+
},
|
114
|
+
"net_total_base_raw":{
|
115
|
+
"description": "Net total unrounded, 6 decimal places. Summed items net_total_base_raw (incl discount)",
|
116
|
+
"readonly":true,
|
117
|
+
"type":"number"
|
118
|
+
}
|
119
|
+
},
|
120
|
+
"links":[
|
121
|
+
{ "rel": "self",
|
122
|
+
"href": "orders/{id}"
|
123
|
+
},
|
124
|
+
{ "rel": "instances",
|
125
|
+
"href": "orders",
|
126
|
+
"properties" : {
|
127
|
+
"page":{
|
128
|
+
"title" : "Page",
|
129
|
+
"description": "In paginated results set the page to look for",
|
130
|
+
"type":"number"
|
131
|
+
},
|
132
|
+
"filter[q]":{
|
133
|
+
"title" : "Search",
|
134
|
+
"description": "Search in title, number, addressfield",
|
135
|
+
"type":"string"
|
136
|
+
},
|
137
|
+
"filter[tags]":{
|
138
|
+
"title" : "Tags",
|
139
|
+
"description": "Filter by a space delimited list of tags",
|
140
|
+
"type":"string"
|
141
|
+
},
|
142
|
+
"filter[from]":{
|
143
|
+
"title" : "From date",
|
144
|
+
"description": "All objects with a date after the date"
|
145
|
+
},
|
146
|
+
"filter[to]":{
|
147
|
+
"title" : "To date",
|
148
|
+
"description": "All objects with date before the date"
|
149
|
+
},
|
150
|
+
"sort_by":{
|
151
|
+
"title" : "Sort by",
|
152
|
+
"description": "Sort the results by the given field => number",
|
153
|
+
"enum":['title', 'number', 'created_at', 'updated_at', 'client_id', 'price_total', 'price_tax', 'date', 'due_date'],
|
154
|
+
"type": 'string'
|
155
|
+
},
|
156
|
+
"sort":{
|
157
|
+
"title" : "Sort",
|
158
|
+
"enum":["ASC","DESC"],
|
159
|
+
"description": "Sort the results in ASC or DESC"
|
160
|
+
}
|
161
|
+
}
|
162
|
+
},
|
163
|
+
{ "rel": "destroy",
|
164
|
+
"href": "orders/{id}",
|
165
|
+
"method": "DELETE"
|
166
|
+
},
|
167
|
+
{ "rel": "update",
|
168
|
+
"href": "orders/{id}",
|
169
|
+
"method": "PUT"
|
170
|
+
},
|
171
|
+
{ "rel": "create",
|
172
|
+
"href": "orders",
|
173
|
+
"method": "POST"
|
174
|
+
},
|
175
|
+
{ "rel": "attachments",
|
176
|
+
"href": "orders/{id}/attachments"
|
177
|
+
},
|
178
|
+
{ "rel": "print",
|
179
|
+
"href": "orders/{id}/print",
|
180
|
+
"method": "POST",
|
181
|
+
"properties" : {
|
182
|
+
"template_id" : {
|
183
|
+
"title" : "PDF template used for printing",
|
184
|
+
"description": "UUID of a pdf template used to print the document. MUST be present",
|
185
|
+
"required":true
|
186
|
+
},
|
187
|
+
"base64" : {
|
188
|
+
"title" : "Return the created pdf base64 encoded",
|
189
|
+
"description": "If set the new pdf is returned inside the attachment JSON within 'base64' key. Leave empty to save traffic."
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
]
|
194
|
+
}
|
@@ -0,0 +1,179 @@
|
|
1
|
+
{ "type":"object",
|
2
|
+
"title": "payment_reminder",
|
3
|
+
"description": "An payment_reminder",
|
4
|
+
"properties":{
|
5
|
+
"id":{
|
6
|
+
"description": "UUID assigned by SK",
|
7
|
+
"identity":true,
|
8
|
+
"readonly":true,
|
9
|
+
"type":"string"
|
10
|
+
},
|
11
|
+
"address_field":{
|
12
|
+
"description": "Receiver address, normally shown in envelope window. Defaults to client address_field if empty and client_id given.",
|
13
|
+
"type":"string"
|
14
|
+
},
|
15
|
+
"date":{
|
16
|
+
"description": "Date the payment_reminder is issued. Automatically set when payment_reminder is opened. Required for non-draft documents.",
|
17
|
+
"format":"date",
|
18
|
+
"type":"string"
|
19
|
+
},
|
20
|
+
"due_days":{
|
21
|
+
"description": "Used to calculate the due date of the payment_reminder. Useless if date and due date are present.",
|
22
|
+
"type":"integer"
|
23
|
+
},
|
24
|
+
"due_date":{
|
25
|
+
"description": "Auto-calculated from date + due days if empty and the payment_reminder is opened.",
|
26
|
+
"format":"date",
|
27
|
+
"type":"string"
|
28
|
+
},
|
29
|
+
"title":{
|
30
|
+
"description": "The headline of a document. Use SK placeholders to prevent exessive typing e.g. 'Your payment_reminder [number]'",
|
31
|
+
"type":"string"
|
32
|
+
},
|
33
|
+
"notes_before":{
|
34
|
+
"description": "Notes shown before the line items. Normaly contains salutation and other introductional information. SK placeholders can be used.",
|
35
|
+
"type":"string"
|
36
|
+
},
|
37
|
+
"notes_after":{
|
38
|
+
"description": "Notes shown after the line items. Can contain information about payments, bank account or a thank-you message. SK placeholders can be used.",
|
39
|
+
"type":"string"
|
40
|
+
},
|
41
|
+
"tag_list": {
|
42
|
+
"description": "Space separated list of tags.",
|
43
|
+
"type":"string"
|
44
|
+
},
|
45
|
+
"precision":{
|
46
|
+
"description": "Decimal places for displayed(printed) money values. gross_total and net_total will always be displayed rounded to a precision of 2. When greater 2 use net_total_base(also in line_item) to show the net val with the set precision(3,4).",
|
47
|
+
"type":"number",
|
48
|
+
"enum": [2,3,4],
|
49
|
+
"default":2
|
50
|
+
},
|
51
|
+
"archived_pdf":{
|
52
|
+
"description": "Archived PDF version of the document. Is created when an document is printed and archived. A document can have multiple archived versions. This only returns the most recent one. ",
|
53
|
+
"readonly":true,
|
54
|
+
"type":"object",
|
55
|
+
"properties":{"$ref":"./attachment.json#properties"}
|
56
|
+
},
|
57
|
+
"client":{
|
58
|
+
"description": "The client for the document. New documents cannot create a client, use client_id field to set it.",
|
59
|
+
"readonly":true,
|
60
|
+
"type":"object",
|
61
|
+
"properties":{"$ref":"./client.json#properties"}
|
62
|
+
},
|
63
|
+
"client_id":{
|
64
|
+
"description": "The clients uuid. New payment_reminders take the clients address field, due days and cash discount if those fields are not set.",
|
65
|
+
"type":"string",
|
66
|
+
"required":true
|
67
|
+
},
|
68
|
+
"team_id":{
|
69
|
+
"description": "A team uuid. If set only the team and its parent teams can see the record.",
|
70
|
+
"type":"string"
|
71
|
+
},
|
72
|
+
"line_items":{
|
73
|
+
"description": "Line items for the document",
|
74
|
+
"type":"array",
|
75
|
+
"properties":{"$ref":"./address.json#properties"}
|
76
|
+
},
|
77
|
+
"created_at":{
|
78
|
+
"description": "Date the object was created in SK. Never changes afterwards.",
|
79
|
+
"format":"date-time",
|
80
|
+
"readonly":true,
|
81
|
+
"type":"string"
|
82
|
+
},
|
83
|
+
"updated_at":{
|
84
|
+
"description": "Date the object was edited in SK.",
|
85
|
+
"format":"date-time",
|
86
|
+
"readonly":true,
|
87
|
+
"type":"string"
|
88
|
+
},
|
89
|
+
"lock_version":{
|
90
|
+
"description": "Auto-incremented to prevent concurrent updateing. First save wins and increments version. ",
|
91
|
+
"optional":true,
|
92
|
+
"type":"integer"
|
93
|
+
},
|
94
|
+
"gross_total":{
|
95
|
+
"description": "Gross total of all line items, 2 decimals places",
|
96
|
+
"readonly":true,
|
97
|
+
"type":"number"
|
98
|
+
},
|
99
|
+
"net_total":{
|
100
|
+
"description": "Net total, 2 decimals places",
|
101
|
+
"readonly":true,
|
102
|
+
"type":"number"
|
103
|
+
}
|
104
|
+
},
|
105
|
+
"links":[
|
106
|
+
{ "rel": "self",
|
107
|
+
"href": "payment_reminders/{id}"
|
108
|
+
},
|
109
|
+
{ "rel": "instances",
|
110
|
+
"href": "payment_reminders",
|
111
|
+
"properties" : {
|
112
|
+
"page":{
|
113
|
+
"title" : "Page",
|
114
|
+
"description": "In paginated results set the page to look for",
|
115
|
+
"type":"number"
|
116
|
+
},
|
117
|
+
"filter[q]":{
|
118
|
+
"title" : "Search",
|
119
|
+
"description": "Search in title, number, addressfield",
|
120
|
+
"type":"string"
|
121
|
+
},
|
122
|
+
"filter[tags]":{
|
123
|
+
"title" : "Tags",
|
124
|
+
"description": "Filter by a space delimited list of tags",
|
125
|
+
"type":"string"
|
126
|
+
},
|
127
|
+
"filter[from]":{
|
128
|
+
"title" : "From date",
|
129
|
+
"description": "All objects with a date after the date"
|
130
|
+
},
|
131
|
+
"filter[to]":{
|
132
|
+
"title" : "To date",
|
133
|
+
"description": "All objects with date before the date"
|
134
|
+
},
|
135
|
+
"sort_by":{
|
136
|
+
"title" : "Sort by",
|
137
|
+
"description": "Sort the results by the given field => number",
|
138
|
+
"enum":['title', 'number', 'created_at', 'updated_at', 'client_id', 'price_total', 'price_tax', 'date', 'due_date'],
|
139
|
+
"type": 'string'
|
140
|
+
},
|
141
|
+
"sort":{
|
142
|
+
"title" : "Sort",
|
143
|
+
"enum":["ASC","DESC"],
|
144
|
+
"description": "Sort the results in ASC or DESC"
|
145
|
+
}
|
146
|
+
}
|
147
|
+
},
|
148
|
+
{ "rel": "destroy",
|
149
|
+
"href": "payment_reminders/{id}",
|
150
|
+
"method": "DELETE"
|
151
|
+
},
|
152
|
+
{ "rel": "update",
|
153
|
+
"href": "payment_reminders/{id}",
|
154
|
+
"method": "PUT"
|
155
|
+
},
|
156
|
+
{ "rel": "create",
|
157
|
+
"href": "payment_reminders",
|
158
|
+
"method": "POST"
|
159
|
+
},
|
160
|
+
{ "rel": "attachments",
|
161
|
+
"href": "payment_reminders/{id}/attachments"
|
162
|
+
},
|
163
|
+
{ "rel": "print",
|
164
|
+
"href": "payment_reminders/{id}/print",
|
165
|
+
"method": "POST",
|
166
|
+
"properties" : {
|
167
|
+
"template_id" : {
|
168
|
+
"title" : "PDF template used for printing",
|
169
|
+
"description": "UUID of a pdf template used to print the document. MUST be present",
|
170
|
+
"required":true
|
171
|
+
},
|
172
|
+
"base64" : {
|
173
|
+
"title" : "Return the created pdf base64 encoded",
|
174
|
+
"description": "If set the new pdf is returned inside the attachment JSON within 'base64' key. Leave empty to save traffic."
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
]
|
179
|
+
}
|
data/lib/sk_api_schema.rb
CHANGED
@@ -4,64 +4,102 @@ module SK
|
|
4
4
|
module Api
|
5
5
|
class Schema
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
class << self
|
8
|
+
# Read a schema with a given version and return it as hash
|
9
|
+
# See ../json folder for available schema's and versions
|
10
|
+
# === Parameter
|
11
|
+
# schema<String|Symbol>::name of the schema, available ones are in json directory
|
12
|
+
# version<String>:: version to read, this is the folder name where the schema is in.
|
13
|
+
# === Return
|
14
|
+
# <HashWithIndifferentAccess>:: schema as hash
|
15
|
+
def read(schema, version)
|
16
|
+
# prefix version with v1.0 of v is not present
|
17
|
+
v = (version =~ /^v/) ? version : "v#{version}"
|
18
|
+
file_path = File.join(File.dirname(__FILE__), '../json', v, "#{schema}.json")
|
19
|
+
plain_data = File.open(file_path, 'r'){|f| f.read}
|
20
|
+
ActiveSupport::JSON.decode(plain_data).with_indifferent_access
|
21
|
+
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
|
40
|
-
#
|
41
|
-
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
23
|
+
# Read all available schemas from a given version(folder) and return
|
24
|
+
# them as array
|
25
|
+
# See ../json folder for available schema's and versions
|
26
|
+
# === Parameter
|
27
|
+
# schema<String|Symbol>::name of the schema, available ones are in json directory
|
28
|
+
# === Return
|
29
|
+
# Array[<HashWithIndifferentAccess>]:: array of schemas as hash
|
30
|
+
def read_all(version)
|
31
|
+
schemas = []
|
32
|
+
v = (version =~ /^v/) ? version : "v#{version}"
|
33
|
+
file_path = File.join(File.dirname(__FILE__), '../json', v, '*.json')
|
34
|
+
Dir.glob( file_path ).each do |file|
|
35
|
+
schema = File.open(file, 'r'){|f| f.read}
|
36
|
+
schemas << ActiveSupport::JSON.decode(schema).with_indifferent_access
|
37
|
+
end
|
38
|
+
schemas
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create a Hash with the available (api)object attributes defined in
|
42
|
+
# schema properties.
|
43
|
+
#
|
44
|
+
# === Example
|
45
|
+
# obj = Invoice.new(:title =>'hello world', :number=>'4711')
|
46
|
+
# obj_hash = Sk::Api::Schema.to_hash_from_schema(obj, 'v1.0')
|
47
|
+
#
|
48
|
+
# obj_hash => { invoice =>{'title'=>'hello world', 'number'=>'4711' } }
|
49
|
+
#
|
50
|
+
# === Parameter
|
51
|
+
# obj<Object>:: An ruby object which is returned as hash
|
52
|
+
# version<String>:: the schema version, must be a valid folder name see #self.read
|
53
|
+
#
|
54
|
+
# === Return
|
55
|
+
# <Hash{String=>{String=>Mixed}}>:: The object as hash:
|
56
|
+
# { invoice =>{'title'=>'hello world', 'number'=>''4711 } }
|
57
|
+
def to_hash_from_schema(obj, version)
|
58
|
+
# get objects class name without inheritance
|
59
|
+
obj_class_name = obj.class.name.split('::').last.underscore
|
60
|
+
# init data hash
|
61
|
+
data = {}
|
62
|
+
# get schema
|
63
|
+
schema = read(obj_class_name, version)
|
64
|
+
# iterate over the defined schema fields
|
65
|
+
schema['properties'].each do |field, prop|
|
66
|
+
if prop['type'] == 'array'
|
67
|
+
data[field] = [] # always set an empty array
|
68
|
+
if rel_objects = obj.send( field )
|
69
|
+
rel_objects.each do |rel_obj|
|
70
|
+
# call related objects to_hash_from_schema method ex:
|
71
|
+
# data[:client][:addresses] << SKApi::Models::Address.to_hash_from_schema(object)
|
72
|
+
data[field] << to_hash_from_schema(rel_obj, version)
|
73
|
+
end
|
51
74
|
end
|
75
|
+
elsif prop['type'] == 'object' # a singular related object
|
76
|
+
data[field] = nil # always set empty val
|
77
|
+
if rel_obj = obj.send( field )
|
78
|
+
#dont nest field to prevent => client=>{client=>{data} }
|
79
|
+
data[field] = to_hash_from_schema(rel_obj, version)
|
80
|
+
end
|
81
|
+
else # a simple field is only added if the object knows it
|
82
|
+
data[field] = obj.send(field) if obj.respond_to?(field.to_sym)
|
52
83
|
end
|
53
|
-
elsif prop['type'] == 'object' # a singular related object
|
54
|
-
data[field] = nil # always set empty val
|
55
|
-
if rel_obj = obj.send( field )
|
56
|
-
data[field] = self.to_hash_from_schema(rel_obj, version)
|
57
|
-
end
|
58
|
-
else # a simple field is only added if objects know its
|
59
|
-
data[field] = obj.send(field) if obj.respond_to?(field.to_sym)
|
60
84
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
85
|
+
#add links
|
86
|
+
{ obj_class_name => data,
|
87
|
+
'links' => parse_links(obj, schema)
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
# Parse the link section of the schema by replacing {id} in urls
|
92
|
+
# === Returns
|
93
|
+
# <Array[Hash{String=>String}]>::
|
94
|
+
def parse_links(obj, schema)
|
95
|
+
links = []
|
96
|
+
schema['links'] && schema['links'].each do |link|
|
97
|
+
links << { 'rel' => link['rel'], 'href' => link['href'].gsub(/\{id\}/, obj.id) }
|
98
|
+
end
|
99
|
+
links.uniq
|
100
|
+
end
|
64
101
|
|
102
|
+
end # class methods
|
65
103
|
end
|
66
104
|
end
|
67
105
|
end
|
data/sk_api_schema.gemspec
CHANGED
@@ -1,46 +1,47 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sk_api_schema}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Georg Leciejewski"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-16}
|
13
13
|
s.description = %q{SalesKing API JSON schema and utility methods}
|
14
14
|
s.email = %q{gl@salesking.eu}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"json/v1.0/address.json",
|
23
|
+
"json/v1.0/attachment.json",
|
24
|
+
"json/v1.0/client.json",
|
25
|
+
"json/v1.0/credit_note.json",
|
26
|
+
"json/v1.0/estimate.json",
|
27
|
+
"json/v1.0/invoice.json",
|
28
|
+
"json/v1.0/line_item.json",
|
29
|
+
"json/v1.0/order.json",
|
30
|
+
"json/v1.0/payment_reminder.json",
|
31
|
+
"json/v1.0/product.json",
|
32
|
+
"json/v1.0/user.json",
|
33
|
+
"lib/sk_api_schema.rb",
|
34
|
+
"sk_api_schema.gemspec",
|
35
|
+
"spec/sk_api_schema_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
35
37
|
]
|
36
38
|
s.homepage = %q{http://github.com/salesking/sk_api_schema}
|
37
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
38
39
|
s.require_paths = ["lib"]
|
39
40
|
s.rubygems_version = %q{1.3.7}
|
40
41
|
s.summary = %q{SalesKing API JSON Schema}
|
41
42
|
s.test_files = [
|
42
|
-
"spec/
|
43
|
-
|
43
|
+
"spec/sk_api_schema_spec.rb",
|
44
|
+
"spec/spec_helper.rb"
|
44
45
|
]
|
45
46
|
|
46
47
|
if s.respond_to? :specification_version then
|
data/spec/sk_api_schema_spec.rb
CHANGED
@@ -10,6 +10,22 @@ describe SK::Api::Schema do
|
|
10
10
|
schema['properties']['id']['identity'].should be_true
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should read json schema file with simple version" do
|
14
|
+
schema = SK::Api::Schema.read(:invoice, '1.0')
|
15
|
+
schema[:title].should == 'invoice'
|
16
|
+
schema[:type].should == 'object'
|
17
|
+
schema['properties'].should be_a Hash
|
18
|
+
schema['properties']['id']['identity'].should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should read all json schemas" do
|
22
|
+
schemas = SK::Api::Schema.read_all('1.0')
|
23
|
+
|
24
|
+
file_path = File.join(File.dirname(__FILE__), '../json', 'v1.0', '*.json')
|
25
|
+
# just check file count
|
26
|
+
schemas.length.should == Dir.glob( file_path ).length
|
27
|
+
end
|
28
|
+
|
13
29
|
it "should raise error if version folder does not exist" do
|
14
30
|
lambda{
|
15
31
|
SK::Api::Schema.read(:invoice, 'v3.0')
|
@@ -45,18 +61,24 @@ describe SK::Api::Schema, 'object parsing' do
|
|
45
61
|
@item.price_single = 0.99
|
46
62
|
end
|
47
63
|
|
48
|
-
it "should parse object
|
64
|
+
it "should parse object with empty relations from schema" do
|
49
65
|
obj_hash = SK::Api::Schema.to_hash_from_schema(@invoice, 'v1.0')
|
50
|
-
|
66
|
+
# {"invoice"=>{"number"=>"911", "line_items"=>[], "archived_pdf"=>nil, "title"=>"Your Invoice", "date"=>nil, "id"=>"some-uuid", "client"=>nil, "due_date"=>nil}}
|
67
|
+
obj_hash.keys.should == ["invoice", "links"]
|
68
|
+
obj_hash['invoice'].should include( "number"=>"911","line_items"=>[],"archived_pdf"=>nil,"id"=>"some-uuid", "title"=>"Your Invoice" )
|
51
69
|
client_obj_hash = SK::Api::Schema.to_hash_from_schema(@client, 'v1.0')
|
52
|
-
client_obj_hash.should ==
|
70
|
+
client_obj_hash.keys.should == ["client", "links"]
|
71
|
+
client_obj_hash['client'].should include("number"=>"911", "addresses"=>[], "id"=>"some-uuid", "organisation"=>"Dirty Food Inc.", "last_name"=>nil)
|
53
72
|
end
|
54
73
|
|
55
74
|
it "should parse object with relations from schema" do
|
56
75
|
@invoice.line_items = [@item]
|
57
76
|
@invoice.client = @client
|
58
77
|
obj_hash = SK::Api::Schema.to_hash_from_schema(@invoice, 'v1.0')
|
59
|
-
obj_hash
|
78
|
+
obj_hash["invoice"]['client']['client'].should == {"number"=>"911", "addresses"=>[], "id"=>"some-uuid", "organisation"=>"Dirty Food Inc.", "last_name"=>nil}
|
79
|
+
obj_hash["invoice"]["client"]['links'].should == []
|
80
|
+
obj_hash["invoice"]["line_items"].should == [ {'links'=>[], "line_item"=>{"name"=>"Pork Chops", "position"=>1, \
|
81
|
+
"id"=>"some-uuid", "description"=>"Yummi Pork chopped by mexian emigrants", "price_single"=>0.99}}]
|
60
82
|
end
|
61
83
|
|
62
84
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sk_api_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Georg Leciejewski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-16 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -55,7 +55,6 @@ extensions: []
|
|
55
55
|
extra_rdoc_files:
|
56
56
|
- README.rdoc
|
57
57
|
files:
|
58
|
-
- .gitignore
|
59
58
|
- README.rdoc
|
60
59
|
- Rakefile
|
61
60
|
- VERSION
|
@@ -63,8 +62,11 @@ files:
|
|
63
62
|
- json/v1.0/attachment.json
|
64
63
|
- json/v1.0/client.json
|
65
64
|
- json/v1.0/credit_note.json
|
65
|
+
- json/v1.0/estimate.json
|
66
66
|
- json/v1.0/invoice.json
|
67
67
|
- json/v1.0/line_item.json
|
68
|
+
- json/v1.0/order.json
|
69
|
+
- json/v1.0/payment_reminder.json
|
68
70
|
- json/v1.0/product.json
|
69
71
|
- json/v1.0/user.json
|
70
72
|
- lib/sk_api_schema.rb
|
@@ -76,8 +78,8 @@ homepage: http://github.com/salesking/sk_api_schema
|
|
76
78
|
licenses: []
|
77
79
|
|
78
80
|
post_install_message:
|
79
|
-
rdoc_options:
|
80
|
-
|
81
|
+
rdoc_options: []
|
82
|
+
|
81
83
|
require_paths:
|
82
84
|
- lib
|
83
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -106,5 +108,5 @@ signing_key:
|
|
106
108
|
specification_version: 3
|
107
109
|
summary: SalesKing API JSON Schema
|
108
110
|
test_files:
|
109
|
-
- spec/spec_helper.rb
|
110
111
|
- spec/sk_api_schema_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
data/.gitignore
DELETED