waveapps 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +8 -0
- data/lib/waveapps.rb +324 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a6cefba77450757d354b40bf8e39b1ebc8ac874d7483b5329104f8ee837a6331
|
4
|
+
data.tar.gz: be9869218c51c5c9de20245dbd44b2e5a40968eea1a8ddeb7a38b824995d4849
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56d5dd9c51b4b85cab2e8e8b565b2061a25681d04cf3d5fcc902457397090649b617bdd3934a1fb5944c5a96674ac9956b8d0ad48b9d876efbd27af0660e713d
|
7
|
+
data.tar.gz: 3aeb1c0ae6e395735f50a9bd76e5dae2bf507e6fae98175761999da1df44b15600bf1b617b43e64ef55d5f24328ea3b8175f6e99b428c646afa170b7628d3882
|
data/Rakefile
ADDED
data/lib/waveapps.rb
ADDED
@@ -0,0 +1,324 @@
|
|
1
|
+
require "waveapps/ruby/version"
|
2
|
+
require "graphql/client"
|
3
|
+
require "graphql/client/http"
|
4
|
+
|
5
|
+
module Waveapps
|
6
|
+
class Error < StandardError; end
|
7
|
+
API_URL = "https://gql.waveapps.com/graphql/public"
|
8
|
+
WAVEAPPS_TOKEN = ENV.fetch('WAVEAPPS_TOKEN')
|
9
|
+
|
10
|
+
HTTP = GraphQL::Client::HTTP.new(API_URL) do
|
11
|
+
def headers(context)
|
12
|
+
# Optionally set any HTTP headers
|
13
|
+
{
|
14
|
+
"Authorization" => "Bearer #{WAVEAPPS_TOKEN}"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Fetch latest schema on init, this will make a network request
|
20
|
+
# Schema = GraphQL::Client.load_schema(HTTP)
|
21
|
+
|
22
|
+
# However, it's smart to dump this to a JSON file and load from disk
|
23
|
+
#
|
24
|
+
# Run it from a script or rake task
|
25
|
+
# rake schema:dump
|
26
|
+
#
|
27
|
+
Schema = GraphQL::Client.load_schema("./tmp/schema.json")
|
28
|
+
|
29
|
+
Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
|
30
|
+
|
31
|
+
class Invoice
|
32
|
+
ListInvoicesQuery = Waveapps::Client.parse <<-'GRAPHQL'
|
33
|
+
query($businessId: ID!, $page: Int!, $pageSize: Int!) {
|
34
|
+
business(id: $businessId) {
|
35
|
+
id
|
36
|
+
isClassicInvoicing
|
37
|
+
invoices(page: $page, pageSize: $pageSize) {
|
38
|
+
pageInfo {
|
39
|
+
currentPage
|
40
|
+
totalPages
|
41
|
+
totalCount
|
42
|
+
}
|
43
|
+
edges {
|
44
|
+
node {
|
45
|
+
id
|
46
|
+
createdAt
|
47
|
+
modifiedAt
|
48
|
+
pdfUrl
|
49
|
+
viewUrl
|
50
|
+
status
|
51
|
+
title
|
52
|
+
subhead
|
53
|
+
invoiceNumber
|
54
|
+
invoiceDate
|
55
|
+
poNumber
|
56
|
+
customer {
|
57
|
+
id
|
58
|
+
name
|
59
|
+
# Can add additional customer fields here
|
60
|
+
}
|
61
|
+
currency {
|
62
|
+
code
|
63
|
+
}
|
64
|
+
dueDate
|
65
|
+
amountDue {
|
66
|
+
value
|
67
|
+
currency {
|
68
|
+
symbol
|
69
|
+
}
|
70
|
+
}
|
71
|
+
amountPaid {
|
72
|
+
value
|
73
|
+
currency {
|
74
|
+
symbol
|
75
|
+
}
|
76
|
+
}
|
77
|
+
taxTotal {
|
78
|
+
value
|
79
|
+
currency {
|
80
|
+
symbol
|
81
|
+
}
|
82
|
+
}
|
83
|
+
total {
|
84
|
+
value
|
85
|
+
currency {
|
86
|
+
symbol
|
87
|
+
}
|
88
|
+
}
|
89
|
+
exchangeRate
|
90
|
+
footer
|
91
|
+
memo
|
92
|
+
disableCreditCardPayments
|
93
|
+
disableBankPayments
|
94
|
+
itemTitle
|
95
|
+
unitTitle
|
96
|
+
priceTitle
|
97
|
+
amountTitle
|
98
|
+
hideName
|
99
|
+
hideDescription
|
100
|
+
hideUnit
|
101
|
+
hidePrice
|
102
|
+
hideAmount
|
103
|
+
items {
|
104
|
+
product {
|
105
|
+
id
|
106
|
+
name
|
107
|
+
# Can add additional product fields here
|
108
|
+
}
|
109
|
+
description
|
110
|
+
quantity
|
111
|
+
price
|
112
|
+
subtotal {
|
113
|
+
value
|
114
|
+
currency {
|
115
|
+
symbol
|
116
|
+
}
|
117
|
+
}
|
118
|
+
total {
|
119
|
+
value
|
120
|
+
currency {
|
121
|
+
symbol
|
122
|
+
}
|
123
|
+
}
|
124
|
+
account {
|
125
|
+
id
|
126
|
+
name
|
127
|
+
subtype {
|
128
|
+
name
|
129
|
+
value
|
130
|
+
}
|
131
|
+
# Can add additional account fields here
|
132
|
+
}
|
133
|
+
taxes {
|
134
|
+
amount {
|
135
|
+
value
|
136
|
+
}
|
137
|
+
salesTax {
|
138
|
+
id
|
139
|
+
name
|
140
|
+
# Can add additional sales tax fields here
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
lastSentAt
|
145
|
+
lastSentVia
|
146
|
+
lastViewedAt
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
GRAPHQL
|
153
|
+
|
154
|
+
def self.list_invoices(page: 1, page_size: 10, business_id:)
|
155
|
+
result = Waveapps::Client.query(ListInvoicesQuery, variables: {
|
156
|
+
businessId: business_id, page: page, pageSize: page_size
|
157
|
+
}).data
|
158
|
+
return nil if result.nil?
|
159
|
+
result.business.invoices.edges.map {|n| n.node}
|
160
|
+
end
|
161
|
+
|
162
|
+
CreateInvoiceQuery = Waveapps::Client.parse <<-'GRAPHQL'
|
163
|
+
mutation ($input: InvoiceCreateInput!) {
|
164
|
+
invoiceCreate(input: $input) {
|
165
|
+
didSucceed
|
166
|
+
inputErrors {
|
167
|
+
message
|
168
|
+
code
|
169
|
+
path
|
170
|
+
}
|
171
|
+
invoice {
|
172
|
+
id
|
173
|
+
createdAt
|
174
|
+
modifiedAt
|
175
|
+
pdfUrl
|
176
|
+
viewUrl
|
177
|
+
status
|
178
|
+
title
|
179
|
+
subhead
|
180
|
+
invoiceNumber
|
181
|
+
invoiceDate
|
182
|
+
poNumber
|
183
|
+
customer {
|
184
|
+
id
|
185
|
+
name
|
186
|
+
# Can add additional customer fields here
|
187
|
+
}
|
188
|
+
currency {
|
189
|
+
code
|
190
|
+
}
|
191
|
+
dueDate
|
192
|
+
amountDue {
|
193
|
+
value
|
194
|
+
currency {
|
195
|
+
symbol
|
196
|
+
}
|
197
|
+
}
|
198
|
+
amountPaid {
|
199
|
+
value
|
200
|
+
currency {
|
201
|
+
symbol
|
202
|
+
}
|
203
|
+
}
|
204
|
+
taxTotal {
|
205
|
+
value
|
206
|
+
currency {
|
207
|
+
symbol
|
208
|
+
}
|
209
|
+
}
|
210
|
+
total {
|
211
|
+
value
|
212
|
+
currency {
|
213
|
+
symbol
|
214
|
+
}
|
215
|
+
}
|
216
|
+
exchangeRate
|
217
|
+
footer
|
218
|
+
memo
|
219
|
+
disableCreditCardPayments
|
220
|
+
disableBankPayments
|
221
|
+
itemTitle
|
222
|
+
unitTitle
|
223
|
+
priceTitle
|
224
|
+
amountTitle
|
225
|
+
hideName
|
226
|
+
hideDescription
|
227
|
+
hideUnit
|
228
|
+
hidePrice
|
229
|
+
hideAmount
|
230
|
+
items {
|
231
|
+
product {
|
232
|
+
id
|
233
|
+
name
|
234
|
+
# Can add additional product fields here
|
235
|
+
}
|
236
|
+
description
|
237
|
+
quantity
|
238
|
+
price
|
239
|
+
subtotal {
|
240
|
+
value
|
241
|
+
currency {
|
242
|
+
symbol
|
243
|
+
}
|
244
|
+
}
|
245
|
+
total {
|
246
|
+
value
|
247
|
+
currency {
|
248
|
+
symbol
|
249
|
+
}
|
250
|
+
}
|
251
|
+
account {
|
252
|
+
id
|
253
|
+
name
|
254
|
+
subtype {
|
255
|
+
name
|
256
|
+
value
|
257
|
+
}
|
258
|
+
# Can add additional account fields here
|
259
|
+
}
|
260
|
+
taxes {
|
261
|
+
amount {
|
262
|
+
value
|
263
|
+
}
|
264
|
+
salesTax {
|
265
|
+
id
|
266
|
+
name
|
267
|
+
# Can add additional sales tax fields here
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
lastSentAt
|
272
|
+
lastSentVia
|
273
|
+
lastViewedAt
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
GRAPHQL
|
278
|
+
|
279
|
+
# {
|
280
|
+
# "input": {
|
281
|
+
# "businessId": "<BUSINESS_ID>",
|
282
|
+
# "customerId": "<CUSTOMER_ID>",
|
283
|
+
# "items": [
|
284
|
+
# {
|
285
|
+
# "productId": "<PRODUCT_ID>"
|
286
|
+
# }
|
287
|
+
# ]
|
288
|
+
# }
|
289
|
+
# }
|
290
|
+
|
291
|
+
def self.create_invoice(items: , business_id: , customer_id: )
|
292
|
+
Waveapps::Client.query(CreateInvoiceQuery, variables: {
|
293
|
+
input: {
|
294
|
+
businessId: business_id,
|
295
|
+
customerId: customer_id,
|
296
|
+
items: items.map { |pid| {
|
297
|
+
productId: pid[:product_id],
|
298
|
+
quantity: pid[:quantity],
|
299
|
+
description: pid[:description],
|
300
|
+
unitPrice: pid[:unit_price]
|
301
|
+
}}
|
302
|
+
}
|
303
|
+
})
|
304
|
+
end
|
305
|
+
|
306
|
+
DeleteInvoiceQuery = Waveapps::Client.parse <<-'GRAPHQL'
|
307
|
+
mutation ($input: InvoiceDeleteInput!) {
|
308
|
+
invoiceDelete(input: $input) {
|
309
|
+
didSucceed
|
310
|
+
inputErrors {
|
311
|
+
code
|
312
|
+
message
|
313
|
+
path
|
314
|
+
}
|
315
|
+
}
|
316
|
+
}
|
317
|
+
GRAPHQL
|
318
|
+
|
319
|
+
def self.delete_invoice(id)
|
320
|
+
result = Waveapps::Client.query(DeleteInvoiceQuery, variables: {input: { id: id}})
|
321
|
+
result.data
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: waveapps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hannah Masila
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: graphql-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.16'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.16'
|
69
|
+
description: WaveApps API Ruby DSL
|
70
|
+
email:
|
71
|
+
- hannahmasila@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- Rakefile
|
77
|
+
- lib/waveapps.rb
|
78
|
+
homepage: https://github.com/metaware/waveapps-ruby
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubygems_version: 3.1.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: WaveApps API Ruby DSL
|
101
|
+
test_files: []
|