printavo-ruby 0.5.0 → 0.5.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c8061b68869c47ca86f6c37dc51d60020c035364ea70c68e68bad1df2f4da6c
4
- data.tar.gz: 1d9c8f4d5805ab82bca17f28891fdc21899f2b166638c4e100e8531c8275073f
3
+ metadata.gz: 34f4d971a1f4d0c685fb6780bc12d7737c915d533bc49c9d96fb5c73522eec58
4
+ data.tar.gz: 687c158df7fa205ac7aa5607bb2c6a7171ee7eac972005b0b5d102cee3b7dd0d
5
5
  SHA512:
6
- metadata.gz: 9b39cbc93da67a0b81114fa7209720d944d6ee87cd77763876191ce907a38498cf9c3020548b4f3f23f2a3a675bdd5b7f6ccf80ba937e1c929372e6cfe00761d
7
- data.tar.gz: ab0e28809466df5269eece7960b2d425c1d4f15db68361c55aa730909bd3662b8ac9f1e256c49218e7cc03febe71c96661d64a2c472bb96bc2aa8c0f8b97ab13
6
+ metadata.gz: 402856b46761b8a924bd92a5e433d99faf0f5aa976b9e7e9e4a2e35ee814dda18e4caddafe40f890507832535e233596e6979a439a26895bf20a8caefe8979ad
7
+ data.tar.gz: dd48f4059d8d5d596e1a3e569cdecaa3842c79713ea2da48c112c86664c42f418c035988bbc9c11e48e337508e6af6aa8f6c9938bacf762eda79a5b2e6366e76
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/client.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Client
4
6
  attr_reader :graphql
@@ -1,9 +1,11 @@
1
1
  # lib/printavo/config.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Config
4
6
  attr_accessor :email, :token, :base_url, :timeout
5
7
 
6
- BASE_URL = 'https://www.printavo.com/api/v2'.freeze
8
+ BASE_URL = 'https://www.printavo.com/api/v2'
7
9
 
8
10
  def initialize
9
11
  @base_url = BASE_URL
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/connection.rb
2
+ # frozen_string_literal: true
3
+
2
4
  require 'faraday'
3
5
  require 'faraday/retry'
4
6
 
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/errors.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Error < StandardError; end
4
6
 
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/graphql_client.rb
2
+ # frozen_string_literal: true
3
+
2
4
  require 'json'
3
5
 
4
6
  module Printavo
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/models/base.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  module Models
4
6
  class Base
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/models/customer.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Customer < Models::Base
4
6
  def id = self['id']
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/models/inquiry.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Inquiry < Models::Base
4
6
  def id = self['id']
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/models/job.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Job < Models::Base
4
6
  def id = self['id']
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/models/order.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Order < Models::Base
4
6
  def id = self['id']
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/models/status.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  class Status < Models::Base
4
6
  def id = self['id']
data/lib/printavo/page.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/page.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  # Wraps a single page of API results with cursor metadata.
4
6
  #
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/resources/base.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  module Resources
4
6
  class Base
@@ -1,70 +1,13 @@
1
1
  # lib/printavo/resources/customers.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  module Resources
4
6
  class Customers < Base
5
- ALL_QUERY = <<~GQL.freeze
6
- query Customers($first: Int, $after: String) {
7
- customers(first: $first, after: $after) {
8
- nodes {
9
- id
10
- firstName
11
- lastName
12
- email
13
- phone
14
- company
15
- }
16
- pageInfo {
17
- hasNextPage
18
- endCursor
19
- }
20
- }
21
- }
22
- GQL
23
-
24
- FIND_QUERY = <<~GQL.freeze
25
- query Customer($id: ID!) {
26
- customer(id: $id) {
27
- id
28
- firstName
29
- lastName
30
- email
31
- phone
32
- company
33
- }
34
- }
35
- GQL
36
-
37
- CREATE_MUTATION = <<~GQL.freeze
38
- mutation CustomerCreate($input: CustomerCreateInput!) {
39
- customerCreate(input: $input) {
40
- id
41
- companyName
42
- primaryContact {
43
- id
44
- firstName
45
- lastName
46
- email
47
- phone
48
- }
49
- }
50
- }
51
- GQL
52
-
53
- UPDATE_MUTATION = <<~GQL.freeze
54
- mutation CustomerUpdate($id: ID!, $input: CustomerInput!) {
55
- customerUpdate(id: $id, input: $input) {
56
- id
57
- companyName
58
- primaryContact {
59
- id
60
- firstName
61
- lastName
62
- email
63
- phone
64
- }
65
- }
66
- }
67
- GQL
7
+ ALL_QUERY = File.read(File.join(__dir__, '../graphql/customers/all.graphql')).freeze
8
+ FIND_QUERY = File.read(File.join(__dir__, '../graphql/customers/find.graphql')).freeze
9
+ CREATE_MUTATION = File.read(File.join(__dir__, '../graphql/customers/create.graphql')).freeze
10
+ UPDATE_MUTATION = File.read(File.join(__dir__, '../graphql/customers/update.graphql')).freeze
68
11
 
69
12
  def all(first: 25, after: nil)
70
13
  fetch_page(first: first, after: after).records
@@ -1,100 +1,13 @@
1
1
  # lib/printavo/resources/inquiries.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  module Resources
4
6
  class Inquiries < Base
5
- ALL_QUERY = <<~GQL.freeze
6
- query Inquiries($first: Int, $after: String) {
7
- inquiries(first: $first, after: $after) {
8
- nodes {
9
- id
10
- nickname
11
- totalPrice
12
- status {
13
- id
14
- name
15
- color
16
- }
17
- customer {
18
- id
19
- firstName
20
- lastName
21
- email
22
- company
23
- }
24
- }
25
- pageInfo {
26
- hasNextPage
27
- endCursor
28
- }
29
- }
30
- }
31
- GQL
32
-
33
- FIND_QUERY = <<~GQL.freeze
34
- query Inquiry($id: ID!) {
35
- inquiry(id: $id) {
36
- id
37
- nickname
38
- totalPrice
39
- status {
40
- id
41
- name
42
- color
43
- }
44
- customer {
45
- id
46
- firstName
47
- lastName
48
- email
49
- company
50
- }
51
- }
52
- }
53
- GQL
54
-
55
- CREATE_MUTATION = <<~GQL.freeze
56
- mutation InquiryCreate($input: InquiryCreateInput!) {
57
- inquiryCreate(input: $input) {
58
- id
59
- nickname
60
- totalPrice
61
- status {
62
- id
63
- name
64
- color
65
- }
66
- customer {
67
- id
68
- firstName
69
- lastName
70
- email
71
- company
72
- }
73
- }
74
- }
75
- GQL
76
-
77
- UPDATE_MUTATION = <<~GQL.freeze
78
- mutation InquiryUpdate($id: ID!, $input: InquiryInput!) {
79
- inquiryUpdate(id: $id, input: $input) {
80
- id
81
- nickname
82
- totalPrice
83
- status {
84
- id
85
- name
86
- color
87
- }
88
- customer {
89
- id
90
- firstName
91
- lastName
92
- email
93
- company
94
- }
95
- }
96
- }
97
- GQL
7
+ ALL_QUERY = File.read(File.join(__dir__, '../graphql/inquiries/all.graphql')).freeze
8
+ FIND_QUERY = File.read(File.join(__dir__, '../graphql/inquiries/find.graphql')).freeze
9
+ CREATE_MUTATION = File.read(File.join(__dir__, '../graphql/inquiries/create.graphql')).freeze
10
+ UPDATE_MUTATION = File.read(File.join(__dir__, '../graphql/inquiries/update.graphql')).freeze
98
11
 
99
12
  def all(first: 25, after: nil)
100
13
  fetch_page(first: first, after: after).records
@@ -1,38 +1,11 @@
1
1
  # lib/printavo/resources/jobs.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  module Resources
4
6
  class Jobs < Base
5
- ALL_QUERY = <<~GQL.freeze
6
- query LineItems($orderId: ID!, $first: Int, $after: String) {
7
- order(id: $orderId) {
8
- lineItems(first: $first, after: $after) {
9
- nodes {
10
- id
11
- name
12
- quantity
13
- price
14
- taxable
15
- }
16
- pageInfo {
17
- hasNextPage
18
- endCursor
19
- }
20
- }
21
- }
22
- }
23
- GQL
24
-
25
- FIND_QUERY = <<~GQL.freeze
26
- query LineItem($id: ID!) {
27
- lineItem(id: $id) {
28
- id
29
- name
30
- quantity
31
- price
32
- taxable
33
- }
34
- }
35
- GQL
7
+ ALL_QUERY = File.read(File.join(__dir__, '../graphql/jobs/all.graphql')).freeze
8
+ FIND_QUERY = File.read(File.join(__dir__, '../graphql/jobs/find.graphql')).freeze
36
9
 
37
10
  def all(order_id:, first: 25, after: nil)
38
11
  fetch_page(order_id: order_id, first: first, after: after).records
@@ -1,123 +1,16 @@
1
1
  # lib/printavo/resources/orders.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  module Resources
4
6
  class Orders < Base
5
- ALL_QUERY = <<~GQL.freeze
6
- query Orders($first: Int, $after: String) {
7
- orders(first: $first, after: $after) {
8
- nodes {
9
- id
10
- nickname
11
- totalPrice
12
- status {
13
- id
14
- name
15
- color
16
- }
17
- customer {
18
- id
19
- firstName
20
- lastName
21
- email
22
- company
23
- }
24
- }
25
- pageInfo {
26
- hasNextPage
27
- endCursor
28
- }
29
- }
30
- }
31
- GQL
32
-
33
- FIND_QUERY = <<~GQL.freeze
34
- query Order($id: ID!) {
35
- order(id: $id) {
36
- id
37
- nickname
38
- totalPrice
39
- status {
40
- id
41
- name
42
- color
43
- }
44
- customer {
45
- id
46
- firstName
47
- lastName
48
- email
49
- company
50
- }
51
- }
52
- }
53
- GQL
54
-
7
+ ALL_QUERY = File.read(File.join(__dir__, '../graphql/orders/all.graphql')).freeze
8
+ FIND_QUERY = File.read(File.join(__dir__, '../graphql/orders/find.graphql')).freeze
55
9
  # Printavo creates orders as quotes first; the mutation is quoteCreate.
56
- CREATE_MUTATION = <<~GQL.freeze
57
- mutation QuoteCreate($input: QuoteCreateInput!) {
58
- quoteCreate(input: $input) {
59
- id
60
- nickname
61
- total
62
- status {
63
- id
64
- name
65
- color
66
- }
67
- customer {
68
- id
69
- firstName
70
- lastName
71
- email
72
- company
73
- }
74
- }
75
- }
76
- GQL
77
-
78
- UPDATE_MUTATION = <<~GQL.freeze
79
- mutation QuoteUpdate($id: ID!, $input: QuoteInput!) {
80
- quoteUpdate(id: $id, input: $input) {
81
- id
82
- nickname
83
- total
84
- status {
85
- id
86
- name
87
- color
88
- }
89
- customer {
90
- id
91
- firstName
92
- lastName
93
- email
94
- company
95
- }
96
- }
97
- }
98
- GQL
99
-
10
+ CREATE_MUTATION = File.read(File.join(__dir__, '../graphql/orders/create.graphql')).freeze
11
+ UPDATE_MUTATION = File.read(File.join(__dir__, '../graphql/orders/update.graphql')).freeze
100
12
  # statusUpdate returns an OrderUnion (Quote | Invoice) — requires fragments.
101
- UPDATE_STATUS_MUTATION = <<~GQL.freeze
102
- mutation StatusUpdate($parentId: ID!, $statusId: ID!) {
103
- statusUpdate(parentId: $parentId, statusId: $statusId) {
104
- ... on Quote {
105
- id
106
- nickname
107
- total
108
- status { id name color }
109
- customer { id firstName lastName email company }
110
- }
111
- ... on Invoice {
112
- id
113
- nickname
114
- total
115
- status { id name color }
116
- customer { id firstName lastName email company }
117
- }
118
- }
119
- }
120
- GQL
13
+ UPDATE_STATUS_MUTATION = File.read(File.join(__dir__, '../graphql/orders/update_status.graphql')).freeze
121
14
 
122
15
  def all(first: 25, after: nil)
123
16
  fetch_page(first: first, after: after).records
@@ -1,32 +1,11 @@
1
1
  # lib/printavo/resources/statuses.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
5
  module Resources
4
6
  class Statuses < Base
5
- ALL_QUERY = <<~GQL.freeze
6
- query Statuses($first: Int, $after: String) {
7
- statuses(first: $first, after: $after) {
8
- nodes {
9
- id
10
- name
11
- color
12
- }
13
- pageInfo {
14
- hasNextPage
15
- endCursor
16
- }
17
- }
18
- }
19
- GQL
20
-
21
- FIND_QUERY = <<~GQL.freeze
22
- query Status($id: ID!) {
23
- status(id: $id) {
24
- id
25
- name
26
- color
27
- }
28
- }
29
- GQL
7
+ ALL_QUERY = File.read(File.join(__dir__, '../graphql/statuses/all.graphql')).freeze
8
+ FIND_QUERY = File.read(File.join(__dir__, '../graphql/statuses/find.graphql')).freeze
30
9
 
31
10
  def all(first: 100, after: nil)
32
11
  fetch_page(first: first, after: after).records
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/version.rb
2
+ # frozen_string_literal: true
3
+
2
4
  module Printavo
3
- VERSION = '0.5.0'.freeze
5
+ VERSION = '0.5.1'
4
6
  end
@@ -1,4 +1,6 @@
1
1
  # lib/printavo/webhooks.rb
2
+ # frozen_string_literal: true
3
+
2
4
  require 'openssl'
3
5
 
4
6
  module Printavo
data/lib/printavo.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # lib/printavo.rb
2
+ # frozen_string_literal: true
3
+
2
4
  require 'faraday'
3
5
  require 'faraday/retry'
4
6
  require 'json'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: printavo-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stan Carver II