waveapps 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f11120a5bb89d6849743ed909fce7f7f131343001281c369eb99db4c2e5d936c
4
- data.tar.gz: 74fd04b8dfda4ae34fa48f5a33ef609085971c71bc3b7b3bc87c76218108ca2d
3
+ metadata.gz: 9e66215891bf39f8cf100360c1a040333352a3e858fb8dc9066e9416609da11f
4
+ data.tar.gz: 5b81d1efa4eb8cbb64851268aaeac04560972fa5233a706d9dd40d21c95017fa
5
5
  SHA512:
6
- metadata.gz: 834d60888c9e5e3cd4ca879edc9d3151882a586c16323a0261663c93d655fb60b046a1793488e63656089f4a66616b125a3c64b4a610b88b8e531298f6a9c194
7
- data.tar.gz: c4129c8d9e03354d79b369037f668fbc5da9b2365ebdb61b9f4db2182ca9fc95e9ec4e7b42f2bfb45fc234a07a913329c63679099038c2e9988ab886b6c2aec3
6
+ metadata.gz: f00d6ea26923a895c71322889959293e416f53ca0e398aabcbb6e50e828c1f0d8b17b36be22936de7f76014d6ce7d1e0ef4bd00fe1d79c20096006fee7fa5d74
7
+ data.tar.gz: bc707487b8a151e6fa30604e57b92bd727bb538566de40b2f208d6e0f8bbf4c40c14b42ecaf4005f0dfdce6e7866c43c24486506bdfe52b56c8febf8a434da57
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.1
7
+ before_install: gem install bundler -v 1.17.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at hannahmasila@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in waveapps-ruby-client.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ waveapps (0.1.4)
5
+ graphql-client (~> 0.16)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.0.3)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
+ concurrent-ruby (1.1.6)
17
+ diff-lcs (1.3)
18
+ graphql (1.10.9)
19
+ graphql-client (0.16.0)
20
+ activesupport (>= 3.0)
21
+ graphql (~> 1.8)
22
+ i18n (1.8.2)
23
+ concurrent-ruby (~> 1.0)
24
+ minitest (5.14.0)
25
+ rake (10.5.0)
26
+ rspec (3.9.0)
27
+ rspec-core (~> 3.9.0)
28
+ rspec-expectations (~> 3.9.0)
29
+ rspec-mocks (~> 3.9.0)
30
+ rspec-core (3.9.2)
31
+ rspec-support (~> 3.9.3)
32
+ rspec-expectations (3.9.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.9.0)
35
+ rspec-mocks (3.9.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-support (3.9.3)
39
+ thread_safe (0.3.6)
40
+ tzinfo (1.2.7)
41
+ thread_safe (~> 0.1)
42
+ zeitwerk (2.3.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ bundler (~> 1.17)
49
+ rake (~> 10.0)
50
+ rspec (~> 3.0)
51
+ waveapps!
52
+
53
+ BUNDLED WITH
54
+ 1.17.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Hannah Masila
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Waveapps
2
+
3
+ The Waveapps Ruby library provides convenient access to the Waveapps GraphQL API from applications written in the Ruby language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.
4
+
5
+ The library provides easy configuration path for fast setup and use. It also has helpers for pagination when listing resources. The `page` and `page_size` attributes will handle pagination in all resources.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'waveapps'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install waveapps
22
+
23
+ ## Usage
24
+
25
+ The library needs to be configured with your account's access token which is available in your Waveapps Account. Set Waveapps.access_token to its value:
26
+
27
+ ```ruby
28
+ require "waveapps"
29
+ Waveapps.access_token = "sjblah_..."
30
+ ```
31
+
32
+
33
+ ### Create invoices
34
+ Replace `<BUSINESS_ID>`, `<CUSTOMER_ID>`, and `<PRODUCT_ID>` with real ids.
35
+
36
+ ```ruby
37
+ Waveapps::Invoice.create_invoice(business_id: <BUSINESS_ID>, customer_id: <CUSTOMER_ID>, items: [{product_id: <PRODUCT_ID>}])
38
+ ```
39
+ Optional arguments
40
+
41
+ `status`, `currency`, `title`, `invoice_number`,
42
+ `po_number`, `invoice_date`, `exchange_rate`, `due_date`,
43
+ `memo`, `footer`, `disable_amex_payments`, `disable_credit_card_payments`,
44
+ `disable_bank_payments`, `item_title`, `unit_title`, `price_title`, `amount_title`, `hide_name`, `hide_description`, `hide_unit`, `hide_price`, `hide_amount`
45
+
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hmasila/waveapps-ruby-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
60
+
61
+ ## Code of Conduct
62
+
63
+ Everyone interacting in the Waveapps project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hmasila/waveapps-ruby-client/blob/master/CODE_OF_CONDUCT.md).
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "waveapps"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Waveapps
4
+ class << self
5
+ attr_accessor :access_token
6
+ end
7
+ class Api
8
+ API_URL = 'https://gql.waveapps.com/graphql/public'
9
+ HTTP = GraphQL::Client::HTTP.new(API_URL) do
10
+ def headers(_context)
11
+ # Optionally set any HTTP headers
12
+ {
13
+ 'Authorization' => "Bearer #{Waveapps.access_token}"
14
+ }
15
+ end
16
+ end
17
+
18
+ # Fetch latest schema on init, this will make a network request
19
+ Schema = GraphQL::Client.load_schema(HTTP)
20
+
21
+ # However, it's smart to dump this to a JSON file and load from disk
22
+ #
23
+ # Run it from a script or rake task
24
+ # rake schema:dump
25
+ #
26
+ # Schema = GraphQL::Client.load_schema("./tmp/schema.json")
27
+
28
+ Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
29
+ end
30
+ end
@@ -0,0 +1,318 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Waveapps
4
+ class Invoice
5
+ ListInvoicesQuery = Waveapps::Api::Client.parse <<-'GRAPHQL'
6
+ query($businessId: ID!, $page: Int!, $pageSize: Int!) {
7
+ business(id: $businessId) {
8
+ id
9
+ isClassicInvoicing
10
+ invoices(page: $page, pageSize: $pageSize) {
11
+ pageInfo {
12
+ currentPage
13
+ totalPages
14
+ totalCount
15
+ }
16
+ edges {
17
+ node {
18
+ id
19
+ createdAt
20
+ modifiedAt
21
+ pdfUrl
22
+ viewUrl
23
+ status
24
+ title
25
+ subhead
26
+ invoiceNumber
27
+ invoiceDate
28
+ poNumber
29
+ customer {
30
+ id
31
+ name
32
+ # Can add additional customer fields here
33
+ }
34
+ currency {
35
+ code
36
+ }
37
+ dueDate
38
+ amountDue {
39
+ value
40
+ currency {
41
+ symbol
42
+ }
43
+ }
44
+ amountPaid {
45
+ value
46
+ currency {
47
+ symbol
48
+ }
49
+ }
50
+ taxTotal {
51
+ value
52
+ currency {
53
+ symbol
54
+ }
55
+ }
56
+ total {
57
+ value
58
+ currency {
59
+ symbol
60
+ }
61
+ }
62
+ exchangeRate
63
+ footer
64
+ memo
65
+ disableCreditCardPayments
66
+ disableBankPayments
67
+ itemTitle
68
+ unitTitle
69
+ priceTitle
70
+ amountTitle
71
+ hideName
72
+ hideDescription
73
+ hideUnit
74
+ hidePrice
75
+ hideAmount
76
+ items {
77
+ product {
78
+ id
79
+ name
80
+ # Can add additional product fields here
81
+ }
82
+ description
83
+ quantity
84
+ price
85
+ subtotal {
86
+ value
87
+ currency {
88
+ symbol
89
+ }
90
+ }
91
+ total {
92
+ value
93
+ currency {
94
+ symbol
95
+ }
96
+ }
97
+ account {
98
+ id
99
+ name
100
+ subtype {
101
+ name
102
+ value
103
+ }
104
+ # Can add additional account fields here
105
+ }
106
+ taxes {
107
+ amount {
108
+ value
109
+ }
110
+ salesTax {
111
+ id
112
+ name
113
+ # Can add additional sales tax fields here
114
+ }
115
+ }
116
+ }
117
+ lastSentAt
118
+ lastSentVia
119
+ lastViewedAt
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ GRAPHQL
126
+
127
+ def self.list_invoices(page: 1, page_size: 10, business_id:)
128
+ result = Waveapps::Api::Client.query(ListInvoicesQuery, variables: {
129
+ businessId: business_id, page: page, pageSize: page_size
130
+ }).data
131
+ return nil if result.business.nil?
132
+
133
+ result.business.invoices.edges.map(&:node)
134
+ end
135
+
136
+ CreateInvoiceQuery = Waveapps::Api::Client.parse <<-'GRAPHQL'
137
+ mutation ($input: InvoiceCreateInput!) {
138
+ invoiceCreate(input: $input) {
139
+ didSucceed
140
+ inputErrors {
141
+ message
142
+ code
143
+ path
144
+ }
145
+ invoice {
146
+ id
147
+ createdAt
148
+ modifiedAt
149
+ pdfUrl
150
+ viewUrl
151
+ status
152
+ title
153
+ subhead
154
+ invoiceNumber
155
+ invoiceDate
156
+ poNumber
157
+ customer {
158
+ id
159
+ name
160
+ # Can add additional customer fields here
161
+ }
162
+ currency {
163
+ code
164
+ }
165
+ dueDate
166
+ amountDue {
167
+ value
168
+ currency {
169
+ symbol
170
+ }
171
+ }
172
+ amountPaid {
173
+ value
174
+ currency {
175
+ symbol
176
+ }
177
+ }
178
+ taxTotal {
179
+ value
180
+ currency {
181
+ symbol
182
+ }
183
+ }
184
+ total {
185
+ value
186
+ currency {
187
+ symbol
188
+ }
189
+ }
190
+ exchangeRate
191
+ footer
192
+ memo
193
+ disableCreditCardPayments
194
+ disableBankPayments
195
+ itemTitle
196
+ unitTitle
197
+ priceTitle
198
+ amountTitle
199
+ hideName
200
+ hideDescription
201
+ hideUnit
202
+ hidePrice
203
+ hideAmount
204
+ items {
205
+ product {
206
+ id
207
+ name
208
+ # Can add additional product fields here
209
+ }
210
+ description
211
+ quantity
212
+ price
213
+ subtotal {
214
+ value
215
+ currency {
216
+ symbol
217
+ }
218
+ }
219
+ total {
220
+ value
221
+ currency {
222
+ symbol
223
+ }
224
+ }
225
+ account {
226
+ id
227
+ name
228
+ subtype {
229
+ name
230
+ value
231
+ }
232
+ # Can add additional account fields here
233
+ }
234
+ taxes {
235
+ amount {
236
+ value
237
+ }
238
+ salesTax {
239
+ id
240
+ name
241
+ # Can add additional sales tax fields here
242
+ }
243
+ }
244
+ }
245
+ lastSentAt
246
+ lastSentVia
247
+ lastViewedAt
248
+ }
249
+ }
250
+ }
251
+ GRAPHQL
252
+
253
+ def self.create_invoice(
254
+ status: "DRAFT", currency: nil, title: nil, invoice_number: nil,
255
+ po_number: nil, invoice_date: nil, exchange_rate: nil, due_date: nil,
256
+ memo: nil, footer: nil, disable_amex_payments: nil, disable_credit_card_payments: nil,
257
+ disable_bank_payments: nil, item_title: nil, unit_title: nil, price_title: nil,
258
+ amount_title: nil, hide_name: nil, hide_description: nil, hide_unit: nil,
259
+ hide_price: nil, hide_amount: nil, items:, business_id:, customer_id:
260
+ )
261
+
262
+ Waveapps::Api::Client.query(CreateInvoiceQuery, variables: {
263
+ input: {
264
+ businessId: business_id,
265
+ customerId: customer_id,
266
+ items: items.map do |pid|
267
+ {
268
+ productId: pid[:product_id],
269
+ quantity: pid[:quantity],
270
+ description: pid[:description],
271
+ unitPrice: pid[:unit_price]
272
+ }
273
+ end,
274
+ status: status,
275
+ currency: currency,
276
+ title: title,
277
+ invoiceNumber: invoice_number,
278
+ poNumber: po_number,
279
+ invoiceDate: invoice_date,
280
+ exchangeRate: exchange_rate,
281
+ dueDate: due_date,
282
+ memo: memo,
283
+ footer: footer,
284
+ disableAmexPayments: disable_amex_payments,
285
+ disableCreditCardPayments: disable_credit_card_payments,
286
+ disableBankPayments: disable_bank_payments,
287
+ itemTitle: item_title,
288
+ unitTitle: unit_title,
289
+ priceTitle: price_title,
290
+ amountTitle: amount_title,
291
+ hideName: hide_name,
292
+ hideDescription: hide_description,
293
+ hideUnit: hide_unit,
294
+ hidePrice: hide_price,
295
+ hideAmount: hide_amount
296
+ }
297
+ })
298
+ end
299
+
300
+ DeleteInvoiceQuery = Waveapps::Api::Client.parse <<-'GRAPHQL'
301
+ mutation ($input: InvoiceDeleteInput!) {
302
+ invoiceDelete(input: $input) {
303
+ didSucceed
304
+ inputErrors {
305
+ code
306
+ message
307
+ path
308
+ }
309
+ }
310
+ }
311
+ GRAPHQL
312
+
313
+ def self.delete_invoice(id)
314
+ result = Waveapps::Api::Client.query(DeleteInvoiceQuery, variables: { input: { id: id } })
315
+ result.data
316
+ end
317
+ end
318
+ end
@@ -1,5 +1,5 @@
1
1
  module Waveapps
2
2
  module Ruby
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
data/lib/waveapps.rb CHANGED
@@ -1,324 +1,11 @@
1
- require "waveapps/ruby/version"
2
- require "graphql/client"
3
- require "graphql/client/http"
1
+ # frozen_string_literal: true
2
+
3
+ require 'waveapps/ruby/version'
4
+ require 'graphql/client'
5
+ require 'graphql/client/http'
6
+ require 'waveapps/api'
7
+ require 'waveapps/invoice'
4
8
 
5
9
  module Waveapps
6
10
  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
11
  end
data/waveapps.gemspec ADDED
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "waveapps/ruby/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "waveapps"
8
+ spec.version = Waveapps::Ruby::VERSION
9
+ spec.authors = ["Hannah Masila"]
10
+ spec.email = ["hannahmasila@gmail.com"]
11
+
12
+ spec.summary = %q{WaveApps GraphQL API Ruby DSL}
13
+ spec.description = %q{WaveApps GraphQL API Ruby DSL}
14
+ spec.homepage = "https://rubygems.org/gems/waveapps-ruby-client"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ #
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/hmasila/waveapps-ruby-client"
24
+ # spec.metadata["changelog_uri"] = "https://github.com/metaware/waveapps-ruby"
25
+ # else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ # end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ # spec.files = ['lib/tasks/schema.rake', 'lib/waveapps/ruby/version.rb', 'lib/waveapps.rb', 'Rakefile']
33
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
+ end
36
+ spec.bindir = "exe"
37
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ["lib"]
39
+
40
+ spec.add_development_dependency "bundler", "~> 1.17"
41
+ spec.add_development_dependency "rake", "~> 10.0"
42
+ spec.add_development_dependency "rspec", "~> 3.0"
43
+ spec.add_dependency 'graphql-client', '~> 0.16'
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waveapps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hannah Masila
@@ -66,21 +66,36 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.16'
69
- description: WaveApps API Ruby DSL
69
+ description: WaveApps GraphQL API Ruby DSL
70
70
  email:
71
71
  - hannahmasila@gmail.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".ruby-version"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE.txt
84
+ - README.md
76
85
  - Rakefile
86
+ - bin/console
87
+ - bin/setup
77
88
  - lib/tasks/schema.rake
78
89
  - lib/waveapps.rb
90
+ - lib/waveapps/api.rb
91
+ - lib/waveapps/invoice.rb
79
92
  - lib/waveapps/ruby/version.rb
80
- homepage: https://github.com/metaware/waveapps-ruby
93
+ - waveapps.gemspec
94
+ homepage: https://rubygems.org/gems/waveapps-ruby-client
81
95
  licenses:
82
96
  - MIT
83
- metadata: {}
97
+ metadata:
98
+ source_code_uri: https://github.com/hmasila/waveapps-ruby-client
84
99
  post_install_message:
85
100
  rdoc_options: []
86
101
  require_paths:
@@ -99,5 +114,5 @@ requirements: []
99
114
  rubygems_version: 3.1.2
100
115
  signing_key:
101
116
  specification_version: 4
102
- summary: WaveApps API Ruby DSL
117
+ summary: WaveApps GraphQL API Ruby DSL
103
118
  test_files: []