beanie 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: 970f7591b8a5105d009145b8fbd3a2cace71a71e
4
- data.tar.gz: 5fba8b349b4dae4a0672d639daf3fb0c58c4dc56
3
+ metadata.gz: 9ccfc1c2ca04c30f1c0620c72a98fd899dcf146d
4
+ data.tar.gz: 045a4d591a51a1c08a99e292ac1e61fe00575b15
5
5
  SHA512:
6
- metadata.gz: 371b019c496a95de24f95555514aeb38fafa58131f36db4eda877cde883be1500738ba8ded89c17830cb25e743dc89591f7c8c9d898a7e7a150f170c8465a7ec
7
- data.tar.gz: 8bdb5db3de4c5f0ec57c8972342a15fabb7431c1564d5d49bf98b548519a2c245e4f04fcc505ca41fafc8ae3502cadc34f76f2d26d0f3b66e94f5361f00a0530
6
+ metadata.gz: 57ac8e1f6aa13fa5850fecd543f19ab712f0c27a683beddda7b654a50ea6d5831746c9d99ec1c0ac8ded10cd5029c8de5ff4b9864404f87aa19935be74047231
7
+ data.tar.gz: 9cbcf5d7813c39f3a0841e8ac1765b347be416157572f8abcb4a1b238e15ecddd372053a0f059fecb4d6e9804dd7642184846c1190a38fd23f65cce238b8d70f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/beanie/api.rb CHANGED
@@ -126,6 +126,10 @@ module Beanie
126
126
  url += "/#{opts[:id]}"
127
127
  opts.delete(:id)
128
128
  end
129
+ if opts[:extension]
130
+ url += "/#{opts[:extension]}"
131
+ opts.delete(:extension)
132
+ end
129
133
  url += ".json"
130
134
  optstr = ""
131
135
  opts.each_key do |key|
@@ -29,7 +29,7 @@
29
29
  #
30
30
  module Beanie
31
31
  class ProductionOrder < Api
32
- attr_accessor :id, :number, :state, :quantity, :notes, :provisioning
32
+ attr_accessor :id, :number, :state, :quantity, :notes
33
33
  attr_accessor :sales_order_id, :bill_of_material_id, :work_centre_group_id
34
34
 
35
35
  #
@@ -40,12 +40,25 @@ module Beanie
40
40
  @state = nil
41
41
  @quantity = nil
42
42
  @notes = nil
43
- @provisioning = nil
44
43
  @sales_order_id = nil
45
44
  @bill_of_material_id = nil
46
45
  @work_centre_group_id = nil
47
46
  end
48
47
 
48
+ #
49
+ # Get the private data
50
+ def private_data
51
+ response = ProductionOrder.get(:url => "/production_orders/#{@id}/private_data")
52
+ response["data"]
53
+ end
54
+
55
+ #
56
+ # Update/set the private data
57
+ def private_data=(data)
58
+ pdata = {:data => data}
59
+ response = ProductionOrder.post(pdata, :url => "/production_orders/#{@id}/private_data")
60
+ end
61
+
49
62
  #
50
63
  # Construct the path a little differently...
51
64
  def construct_path(opts = {})
@@ -29,7 +29,24 @@
29
29
  #
30
30
  module Beanie
31
31
  class SalesOrder < Api
32
- attr_accessor :id, :cash_customer_ref, :number, :date, :title, :your_ref, :currency, :customer_id
32
+ attr_accessor :id, :cash_customer_ref, :number, :date, :title, :billing_frequency
33
+ attr_accessor :your_ref, :currency_id, :customer_id
34
+
35
+ BILL_FREQUENCY_DAILY = 0
36
+ BILL_FREQUENCY_WEEKLY = 1
37
+ BILL_FREQUENCY_FORTNIGHTLY = 2
38
+ BILL_FREQUENCY_MONTHLY = 3
39
+ BILL_FREQUENCY_QUARTERLY = 4
40
+ BILL_FREQUENCY_ANNUALLY = 5
41
+
42
+ BILL_FREQUENCY_NAMES = [
43
+ ["Daily", BILL_FREQUENCY_DAILY],
44
+ ["Weekly", BILL_FREQUENCY_WEEKLY],
45
+ ["Fortnightly", BILL_FREQUENCY_FORTNIGHTLY],
46
+ ["Monthly", BILL_FREQUENCY_MONTHLY],
47
+ ["Quarterly", BILL_FREQUENCY_QUARTERLY],
48
+ ["Yearly", BILL_FREQUENCY_ANNUALLY]
49
+ ].freeze
33
50
 
34
51
  #
35
52
  # Initialize instance variables
@@ -39,9 +56,19 @@ module Beanie
39
56
  @number = nil
40
57
  @date = nil
41
58
  @title = nil
59
+ @billing_frequency = BILL_FREQUENCY_DAILY
42
60
  @your_ref = nil
43
61
  @currency = nil
44
62
  @customer_id = nil
45
63
  end
64
+
65
+ #
66
+ # Pretty name for the frequency
67
+ def frequency_name
68
+ BILL_FREQUENCY_NAMES.each do |fn|
69
+ return fn[0] if fn[1] == self.billing_frequency
70
+ end
71
+ return "Unknown?"
72
+ end
46
73
  end
47
74
  end
@@ -29,7 +29,7 @@
29
29
  #
30
30
  module Beanie
31
31
  class SalesOrderItem < Api
32
- attr_accessor :id, :completion, :description, :discount, :frequency, :quantity, :rundate, :state
32
+ attr_accessor :id, :completion, :description, :discount, :quantity, :rundate, :state
33
33
  attr_accessor :sales_order_id, :product_id, :service_period, :unit_cost, :sales_tax
34
34
 
35
35
  STATE_NEW = 0
@@ -44,20 +44,6 @@ module Beanie
44
44
  ["Blocked", STATE_BLOCKED]
45
45
  ].freeze
46
46
 
47
- BILL_FREQUENCY_IMMEDIATE = 0
48
- BILL_FREQUENCY_WEEKLY = 1
49
- BILL_FREQUENCY_MONTHLY = 2
50
- BILL_FREQUENCY_QUARTERLY = 3
51
- BILL_FREQUENCY_ANNUALLY = 4
52
-
53
- BILL_FREQUENCY_NAMES = [
54
- ["Immediate", BILL_FREQUENCY_IMMEDIATE],
55
- ["Weekly", BILL_FREQUENCY_WEEKLY],
56
- ["Monthly", BILL_FREQUENCY_MONTHLY],
57
- ["Quarterly", BILL_FREQUENCY_QUARTERLY],
58
- ["Yearly", BILL_FREQUENCY_ANNUALLY]
59
- ].freeze
60
-
61
47
  SERVICE_PERIOD_ONEOFF = 0
62
48
  SERVICE_PERIOD_HOURLY = 1
63
49
  SERVICE_PERIOD_DAILY = 2
@@ -83,7 +69,6 @@ module Beanie
83
69
  @completion = nil
84
70
  @description = nil
85
71
  @discount = nil
86
- @frequency = nil
87
72
  @quantity = nil
88
73
  @rundate = nil
89
74
  @state = nil
@@ -100,15 +85,6 @@ module Beanie
100
85
  STATE_NAMES[state][0]
101
86
  end
102
87
 
103
- #
104
- # Pretty name for the frequency
105
- def frequency_name
106
- BILL_FREQUENCY_NAMES.each do |fn|
107
- return fn[0] if fn[1] == self.frequency
108
- end
109
- return "Unknown?"
110
- end
111
-
112
88
  #
113
89
  # Service period name
114
90
  def period_name
@@ -132,5 +108,19 @@ module Beanie
132
108
  def one_off?
133
109
  self.service_period == SERVICE_PERIOD_ONEOFF
134
110
  end
111
+
112
+ #
113
+ # Get the private data
114
+ def private_data
115
+ response = SalesOrderItem.get(:url => "/sales_order_items/#{@id}/private_data")
116
+ response["data"]
117
+ end
118
+
119
+ #
120
+ # Update/set the private data
121
+ def private_data=(data)
122
+ pdata = {:data => data}
123
+ response = SalesOrderItem.post(pdata, :url => "/sales_order_items/#{@id}/private_data")
124
+ end
135
125
  end
136
126
  end
@@ -28,5 +28,5 @@
28
28
  # POSSIBILITY OF SUCH DAMAGE.
29
29
  #
30
30
  module Beanie
31
- VERSION = "0.1.0"
31
+ VERSION = "0.1.1"
32
32
  end
@@ -42,31 +42,26 @@ module Beanie
42
42
  end
43
43
 
44
44
  #
45
- # Find all work centres under a specific work centre group
46
- def self.find_all_by_group(work_centre_group_id)
47
- all = []
48
- data = self.get(:url => "/work_centre_groups/#{work_centre_group_id}/work_centres")
49
- data['work_centres'].each do |wc_data|
50
- wc = new
51
- wc.populate(wc_data, :id, :name, :location, :description)
52
- all << wc
53
- end
54
- all
45
+ # Get the private data
46
+ def private_data
47
+ response = WorkCentre.get(:url => "/work_centres/#{@id}/private_data")
48
+ response["data"]
55
49
  end
56
50
 
57
51
  #
58
- # Get the provisioning data
59
- def provisioning
60
- response = WorkCentre.get(:url => "/work_centres/#{@id}/provisioning")
61
- response["data"]
52
+ # Update/set the private data
53
+ def private_data=(data)
54
+ pdata = {:data => data}
55
+ response = WorkCentre.post(pdata, :url => "/work_centres/#{@id}/private_data")
62
56
  end
63
57
 
64
58
  #
65
- # Update/set the provisioning data
66
- def provisioning=(data)
67
- pdata = {:data => data}
68
- response = WorkCentre.post(pdata, :url => "/work_centres/#{@id}/provisioning")
69
- p response
59
+ # Construct the path a little differently...
60
+ def construct_path(opts = {})
61
+ raise ":work_centre_group_id is not defined" unless opts[:work_centre_group_id]
62
+ path = "/work_centre_groups/#{opts[:work_centre_group_id]}/work_centres"
63
+ opts.delete(:work_centre_group_id)
64
+ path
70
65
  end
71
66
  end
72
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beanie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dermot Tynan