fixably 0.1.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdd2d8cd3fb2feb9a44e920cfe03b421911e09d70808d6ba69268699ce557349
4
- data.tar.gz: 974d79e711fd2bdaf019ccbca392a75cfbe9b754cc698b7b5de792acf03bb819
3
+ metadata.gz: a9d5277a0ba5d3af5ae44a46535773a0d37abced3961e2dec3b43b04fe7d31e3
4
+ data.tar.gz: e3fd8a7cfa9ce0ac0702301bacce2423e8654970afab2cdf4aeeb6f3629a009a
5
5
  SHA512:
6
- metadata.gz: b13cdf4844e36560af8581b62e7588823818801a7ebeeac470a6feea0da824646c3ef968ee71da60a1bc636fa908591c910e1818eb5a945d787432087b8c3fa2
7
- data.tar.gz: 19bff33581a964cddf870f33f1ba96a6b2986958240fb5f6e8fc1f693be032e3e9f12d2cf2b4c7fa008d59a9d881bc5ca71f97d13d308cd72a926f07dbb367f8
6
+ metadata.gz: '0941d4b684ab7e4dc37a1f930207e8cd9a922779ed0371f51e07a518c594e9fc33320d917bf24bd99b968e4e9e33c83388fc06c85c4b7ebb26c7cad516296467'
7
+ data.tar.gz: 2f74f0fd34354408ada06e2a5442f75fa1dd4c83b805c021a90292414a49c617166cfd99640b9c8f3f1a07a1e57089547f2e107d0a918e227b1efee99cf0b332
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fixably (0.1.0)
4
+ fixably (0.5.0)
5
5
  activeresource (~> 5)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -116,6 +116,7 @@ Currently supported resources:
116
116
  - Fixably::Customer ([documentation](docs/customer.md))
117
117
  - Fixably::Customer::Child ([documentation](docs/customer/child.md))
118
118
  - Fixably::Device ([documentation](docs/device.md))
119
+ - Fixably::Location ([documentation](docs/location.md))
119
120
  - Fixably::Order ([documentation](docs/order.md))
120
121
  - Fixably::Order::Line ([documentation](docs/order/line.md))
121
122
  - Fixably::Order::Note ([documentation](docs/order/note.md))
@@ -7,7 +7,7 @@ The Fixably API does not allow children to be searched
7
7
  ## Get a child
8
8
 
9
9
  ```ruby
10
- Fixably::Customer::Child.find(1000, customer_id: 1000)
10
+ Fixably::Customer::Child.find(1_000, customer_id: 1_000)
11
11
  ```
12
12
 
13
13
  ## Create a child
data/docs/location.md ADDED
@@ -0,0 +1,33 @@
1
+ # Fixably::Location
2
+
3
+ ## List location
4
+
5
+ ```ruby
6
+ Fixably::Location.all
7
+ Fixably::Location.where(name: "Our location")
8
+ ```
9
+
10
+ ### Include associations in a list
11
+
12
+ **Deliveries**
13
+ Currently not implemented
14
+
15
+ ## Get a location
16
+
17
+ ```ruby
18
+ Fixably::Location.find(1_000)
19
+ Fixably::Location.first
20
+ Fixably::Location.last
21
+ ```
22
+
23
+ ## Create a location
24
+
25
+ The Fixably API does not allow locations to be created
26
+
27
+ ## Update a location
28
+
29
+ The Fixably API does not allow locations to be updated
30
+
31
+ ## Destroy a location
32
+
33
+ The Fixably API does not allow locations to be destroyed
data/docs/order/line.md CHANGED
@@ -3,15 +3,15 @@
3
3
  ## List order lines
4
4
 
5
5
  ```ruby
6
- Fixably::Order::Line.all(order_id: 1000)
6
+ Fixably::Order::Line.all(order_id: 1_000)
7
7
  ```
8
8
 
9
9
  ## Get an order line
10
10
 
11
11
  ```ruby
12
- Fixably::Order::Line.find(1000, order_id: 1000)
13
- Fixably::Order::Line.first(order_id: 1000)
14
- Fixably::Order::Line.last(order_id: 1000)
12
+ Fixably::Order::Line.find(1_000, order_id: 1_000)
13
+ Fixably::Order::Line.first(order_id: 1_000)
14
+ Fixably::Order::Line.last(order_id: 1_000)
15
15
  ```
16
16
 
17
17
  ## Create an order line
data/docs/order/note.md CHANGED
@@ -3,15 +3,22 @@
3
3
  ## List order notes
4
4
 
5
5
  ```ruby
6
- Fixably::Order::Note.all(order_id: 1000)
6
+ Fixably::Order::Note.all(order_id: 1_000)
7
+ ```
8
+
9
+ ### Include associations in a list
10
+
11
+ **Created by**
12
+ ```ruby
13
+ Fixably::Order.includes(:created_by).all(order_id: 1_000)
7
14
  ```
8
15
 
9
16
  ## Get an order note
10
17
 
11
18
  ```ruby
12
- Fixably::Order::Note.find(1000, order_id: 1000)
13
- Fixably::Order::Note.first(order_id: 1000)
14
- Fixably::Order::Note.last(order_id: 1000)
19
+ Fixably::Order::Note.find(1_000, order_id: 1_000)
20
+ Fixably::Order::Note.first(order_id: 1_000)
21
+ Fixably::Order::Note.last(order_id: 1_000)
15
22
  ```
16
23
 
17
24
  ## Create an order note
data/docs/order/task.md CHANGED
@@ -3,15 +3,15 @@
3
3
  ## List order tasks
4
4
 
5
5
  ```ruby
6
- Fixably::Order::Task.all(order_id: 1000)
6
+ Fixably::Order::Task.all(order_id: 1_000)
7
7
  ```
8
8
 
9
9
  ## Get an order task
10
10
 
11
11
  ```ruby
12
- Fixably::Order::Task.find(1000, order_id: 1000)
13
- Fixably::Order::Task.first(order_id: 1000)
14
- Fixably::Order::Task.last(order_id: 1000)
12
+ Fixably::Order::Task.find(1_000, order_id: 1_000)
13
+ Fixably::Order::Task.first(order_id: 1_000)
14
+ Fixably::Order::Task.last(order_id: 1_000)
15
15
  ```
16
16
 
17
17
  ## Create an order task
data/docs/order.md CHANGED
@@ -37,6 +37,12 @@ Fixably::Order.includes(:handled_by).all
37
37
  Fixably::Order.includes(:handled_by).where(internal_location: "SERVICE")
38
38
  ```
39
39
 
40
+ **Location**
41
+ ```ruby
42
+ Fixably::Order.includes(:location).all
43
+ Fixably::Order.includes(:location).where(internal_location: "SERVICE")
44
+ ```
45
+
40
46
  **Ordered by**
41
47
  ```ruby
42
48
  Fixably::Order.includes(:ordered_by).all
@@ -73,7 +79,7 @@ Fixably::Order.includes(:tasks).all
73
79
  Fixably::Order.includes(:tasks).where(internal_location: "SERVICE")
74
80
  ```
75
81
 
76
- ## Get a customer
82
+ ## Get an order
77
83
 
78
84
  ```ruby
79
85
  Fixably::Order.find(1_000)
@@ -33,12 +33,13 @@ module Fixably
33
33
  end
34
34
 
35
35
  def expand_association(association)
36
+ association_name = association.to_s.camelize(:lower)
36
37
  relationship = reflections.fetch(association).macro
37
38
  case relationship
38
39
  when :has_one
39
- association
40
+ association_name
40
41
  when :has_many
41
- "#{association}(items)"
42
+ "#{association_name}(items)"
42
43
  else
43
44
  raise ArgumentError, "Unknown relationship, #{relationship}"
44
45
  end
@@ -17,14 +17,14 @@ module Fixably
17
17
 
18
18
  def remove_on_encode = %w[created_at href id]
19
19
 
20
- private
21
-
22
20
  def remove_has_many_associations(attrs)
23
21
  reflections.select { _2.macro.equal?(:has_many) }.keys.each do
24
22
  attrs.delete(_1)
25
23
  end
26
24
  end
27
25
 
26
+ private
27
+
28
28
  def remove_unallowed_parameters(attrs)
29
29
  remove_on_encode.each { attrs.delete(_1) }
30
30
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fixably
4
+ class Location < ApplicationResource
5
+ actions %i[list show]
6
+
7
+ # TODO
8
+ # has_many :deliveries
9
+ end
10
+ end
@@ -14,6 +14,7 @@ module Fixably
14
14
  has_one :customer, class_name: "fixably/customer"
15
15
  has_one :device, class_name: "fixably/device"
16
16
  has_one :handled_by, class_name: "fixably/customer"
17
+ has_one :location, class_name: "fixably/location"
17
18
  has_one :ordered_by, class_name: "fixably/customer"
18
19
  has_one :queue, class_name: "fixably/queue"
19
20
  has_one :status, class_name: "fixably/status"
@@ -23,7 +24,6 @@ module Fixably
23
24
  has_many :tasks, class_name: "fixably/order/task"
24
25
 
25
26
  # TODO
26
- # has_one :location
27
27
  # has_one :store
28
28
 
29
29
  ALLOWED_INTERNAL_LOCATIONS =
@@ -39,6 +39,15 @@ module Fixably
39
39
  allow_nil: true
40
40
  )
41
41
 
42
+ protected
43
+
44
+ def remove_has_many_associations(attrs)
45
+ reflections.select { |_, reflection| reflection.macro.equal?(:has_many) }.
46
+ keys.
47
+ reject { _1.equal?(:notes) }.
48
+ each { attrs.delete(_1) }
49
+ end
50
+
42
51
  class Contact < ApplicationResource
43
52
  schema do
44
53
  string :full_name
@@ -71,17 +80,12 @@ module Fixably
71
80
  string :text
72
81
  string :type
73
82
  end
83
+
84
+ has_one :created_by, class_name: "fixably/user"
74
85
  end
75
86
 
76
87
  class Task < ApplicationResource
77
- actions %i[list show update]
78
-
79
- # TODO
80
- # has_one :task
81
-
82
- def update
83
- raise "Updating order tasks has not been implemented"
84
- end
88
+ actions %i[list show]
85
89
  end
86
90
  end
87
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fixably
4
- VERSION = "0.1.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/fixably.rb CHANGED
@@ -11,6 +11,7 @@ require "fixably/version"
11
11
  require_relative "fixably/application_resource"
12
12
  require_relative "fixably/resources/customer"
13
13
  require_relative "fixably/resources/device"
14
+ require_relative "fixably/resources/location"
14
15
  require_relative "fixably/resources/order"
15
16
  require_relative "fixably/resources/queue"
16
17
  require_relative "fixably/resources/status"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixably
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Rice
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-12 00:00:00.000000000 Z
11
+ date: 2021-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -160,6 +160,7 @@ files:
160
160
  - docs/customer.md
161
161
  - docs/customer/child.md
162
162
  - docs/device.md
163
+ - docs/location.md
163
164
  - docs/order.md
164
165
  - docs/order/line.md
165
166
  - docs/order/note.md
@@ -184,6 +185,7 @@ files:
184
185
  - lib/fixably/resource_lazy_loader.rb
185
186
  - lib/fixably/resources/customer.rb
186
187
  - lib/fixably/resources/device.rb
188
+ - lib/fixably/resources/location.rb
187
189
  - lib/fixably/resources/order.rb
188
190
  - lib/fixably/resources/queue.rb
189
191
  - lib/fixably/resources/status.rb