beanie 0.1.2 → 0.1.3
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 +4 -4
 - data/VERSION +1 -1
 - data/beanie.gemspec +1 -1
 - data/lib/beanie/api.rb +15 -2
 - data/lib/beanie/company.rb +1 -2
 - data/lib/beanie/nominal_account.rb +31 -1
 - data/lib/beanie/nominal_account_category.rb +2 -26
 - data/lib/beanie/product.rb +2 -3
 - data/lib/beanie/production_order.rb +8 -3
 - data/lib/beanie/version.rb +1 -1
 - data/lib/beanie/work_centre.rb +30 -4
 - data/lib/beanie.rb +3 -4
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0be70757db5a53fe03f310cbc2e939455c1a2020
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1d90afd4f7c703df8038554cd1a075a2d8f4000a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 518c5a6921a048676986efaa57d95281974556baa922368fff212789bbb269ab930782d0209a4ecc2739ce1bc72870abb749a3dea4787e7dba27d6d7b1b161d8
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 65d45ed530e4f7a2aecc8b99844882c3f70889fee8febad718a3437de8f00f83aa9dc2d122d86c62b657e16bdc484f9e650ac5ef3f5d8e9562a34332e1354d4c
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.1. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.1.3
         
     | 
    
        data/beanie.gemspec
    CHANGED
    
    | 
         @@ -10,7 +10,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       10 
10 
     | 
    
         
             
              spec.email         = ["dtynan@kalopa.com"]
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.summary       = %q{Ruby bindings for the Beanie API}
         
     | 
| 
       12 
12 
     | 
    
         
             
              spec.description   = %q{Beanie - your cloud accountant. See https://bean.ie for more details.}
         
     | 
| 
       13 
     | 
    
         
            -
              spec.homepage      = "https://bean.ie/ 
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://bean.ie/help/api/ruby"
         
     | 
| 
       14 
14 
     | 
    
         
             
              spec.license       = "MIT"
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              spec.files         = `git ls-files`.split($/)
         
     | 
    
        data/lib/beanie/api.rb
    CHANGED
    
    | 
         @@ -56,7 +56,16 @@ module Beanie 
     | 
|
| 
       56 
56 
     | 
    
         
             
                  data = extract()
         
     | 
| 
       57 
57 
     | 
    
         
             
                  data.delete("id")
         
     | 
| 
       58 
58 
     | 
    
         
             
                  objdata = {object_name => data}
         
     | 
| 
       59 
     | 
    
         
            -
                   
     | 
| 
      
 59 
     | 
    
         
            +
                  if @id
         
     | 
| 
      
 60 
     | 
    
         
            +
                    #
         
     | 
| 
      
 61 
     | 
    
         
            +
                    # Needs an update...
         
     | 
| 
      
 62 
     | 
    
         
            +
                    opts[:id] = @id
         
     | 
| 
      
 63 
     | 
    
         
            +
                    response = self.class.put(objdata, opts)
         
     | 
| 
      
 64 
     | 
    
         
            +
                else
         
     | 
| 
      
 65 
     | 
    
         
            +
                    #
         
     | 
| 
      
 66 
     | 
    
         
            +
                    # Needs a create!
         
     | 
| 
      
 67 
     | 
    
         
            +
                    response = self.class.post(objdata, opts)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
       60 
69 
     | 
    
         
             
                  self.populate(response[self.object_name])
         
     | 
| 
       61 
70 
     | 
    
         
             
                end
         
     | 
| 
       62 
71 
     | 
    
         | 
| 
         @@ -96,7 +105,11 @@ module Beanie 
     | 
|
| 
       96 
105 
     | 
    
         
             
                # Run a REST PUT against the Beanie API.
         
     | 
| 
       97 
106 
     | 
    
         
             
                def self.put(data, opts = {})
         
     | 
| 
       98 
107 
     | 
    
         
             
                  response = RestClient.put(build_url(opts), data, headers=set_headers)
         
     | 
| 
       99 
     | 
    
         
            -
                   
     | 
| 
      
 108 
     | 
    
         
            +
                  if response.body and response.body.length > 0
         
     | 
| 
      
 109 
     | 
    
         
            +
                    JSON.parse(response.body)
         
     | 
| 
      
 110 
     | 
    
         
            +
                  else
         
     | 
| 
      
 111 
     | 
    
         
            +
                    ""
         
     | 
| 
      
 112 
     | 
    
         
            +
                  end
         
     | 
| 
       100 
113 
     | 
    
         
             
                end
         
     | 
| 
       101 
114 
     | 
    
         | 
| 
       102 
115 
     | 
    
         
             
                #
         
     | 
    
        data/lib/beanie/company.rb
    CHANGED
    
    | 
         @@ -31,7 +31,7 @@ module Beanie 
     | 
|
| 
       31 
31 
     | 
    
         
             
              class Company < Api
         
     | 
| 
       32 
32 
     | 
    
         
             
                attr_accessor :id, :name, :email, :address1, :address2, :address3, :city
         
     | 
| 
       33 
33 
     | 
    
         
             
                attr_accessor :state_county, :website, :phone, :fax, :zip_postcode
         
     | 
| 
       34 
     | 
    
         
            -
                attr_accessor :registration, :next_fye, : 
     | 
| 
      
 34 
     | 
    
         
            +
                attr_accessor :registration, :next_fye, :country, :currency
         
     | 
| 
       35 
35 
     | 
    
         
             
                attr_accessor :invoice_template_id, :purchase_shipping_nominal_account_id
         
     | 
| 
       36 
36 
     | 
    
         
             
                attr_accessor :sales_shipping_nominal_account_id
         
     | 
| 
       37 
37 
     | 
    
         
             
                attr_accessor :accounts_receivable_nominal_account_id
         
     | 
| 
         @@ -54,7 +54,6 @@ module Beanie 
     | 
|
| 
       54 
54 
     | 
    
         
             
                  @zip_postcode = nil
         
     | 
| 
       55 
55 
     | 
    
         
             
                  @registration = nil
         
     | 
| 
       56 
56 
     | 
    
         
             
                  @next_fye = nil
         
     | 
| 
       57 
     | 
    
         
            -
                  @runcom = nil
         
     | 
| 
       58 
57 
     | 
    
         
             
                  @country = nil
         
     | 
| 
       59 
58 
     | 
    
         
             
                  @currency = nil
         
     | 
| 
       60 
59 
     | 
    
         
             
                  @invoice_template_id = nil
         
     | 
| 
         @@ -29,7 +29,31 @@ 
     | 
|
| 
       29 
29 
     | 
    
         
             
            #
         
     | 
| 
       30 
30 
     | 
    
         
             
            module Beanie
         
     | 
| 
       31 
31 
     | 
    
         
             
              class NominalAccount < Api
         
     | 
| 
       32 
     | 
    
         
            -
                attr_accessor :id, :code, :name, :nominal_account_category_id
         
     | 
| 
      
 32 
     | 
    
         
            +
                attr_accessor :id, :na_type, :code, :name, :nominal_account_category_id
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                TYPE_FIXED_ASSETS = 0
         
     | 
| 
      
 35 
     | 
    
         
            +
                TYPE_CURRENT_ASSETS = 1
         
     | 
| 
      
 36 
     | 
    
         
            +
                TYPE_CURRENT_LIABILITIES = 2
         
     | 
| 
      
 37 
     | 
    
         
            +
                TYPE_NON_CURRENT_LIABILITIES = 3
         
     | 
| 
      
 38 
     | 
    
         
            +
                TYPE_RESERVES = 4
         
     | 
| 
      
 39 
     | 
    
         
            +
                TYPE_INCOME = 5
         
     | 
| 
      
 40 
     | 
    
         
            +
                TYPE_DIRECT_COSTS = 6
         
     | 
| 
      
 41 
     | 
    
         
            +
                TYPE_EXPENSE = 7
         
     | 
| 
      
 42 
     | 
    
         
            +
                TYPE_OTHER_EXPENSE = 8
         
     | 
| 
      
 43 
     | 
    
         
            +
                TYPE_OTHER_INCOME = 9
         
     | 
| 
      
 44 
     | 
    
         
            +
              
         
     | 
| 
      
 45 
     | 
    
         
            +
                TYPE_NAMES = [
         
     | 
| 
      
 46 
     | 
    
         
            +
                  ["Fixed Assets", TYPE_FIXED_ASSETS],
         
     | 
| 
      
 47 
     | 
    
         
            +
                  ["Current Assets", TYPE_CURRENT_ASSETS],
         
     | 
| 
      
 48 
     | 
    
         
            +
                  ["Current Liabilities", TYPE_CURRENT_LIABILITIES],
         
     | 
| 
      
 49 
     | 
    
         
            +
                  ["Non-Current Liabilities", TYPE_NON_CURRENT_LIABILITIES],
         
     | 
| 
      
 50 
     | 
    
         
            +
                  ["Reserves", TYPE_RESERVES],
         
     | 
| 
      
 51 
     | 
    
         
            +
                  ["Income", TYPE_INCOME],
         
     | 
| 
      
 52 
     | 
    
         
            +
                  ["Direct Costs", TYPE_DIRECT_COSTS],
         
     | 
| 
      
 53 
     | 
    
         
            +
                  ["Expense", TYPE_EXPENSE],
         
     | 
| 
      
 54 
     | 
    
         
            +
                  ["Other Expense", TYPE_OTHER_EXPENSE],
         
     | 
| 
      
 55 
     | 
    
         
            +
                  ["Other Income", TYPE_OTHER_INCOME]
         
     | 
| 
      
 56 
     | 
    
         
            +
                ].freeze
         
     | 
| 
       33 
57 
     | 
    
         | 
| 
       34 
58 
     | 
    
         
             
                #
         
     | 
| 
       35 
59 
     | 
    
         
             
                # Initialize instance variables
         
     | 
| 
         @@ -39,5 +63,11 @@ module Beanie 
     | 
|
| 
       39 
63 
     | 
    
         
             
                  @name = nil
         
     | 
| 
       40 
64 
     | 
    
         
             
                  @nominal_account_category_id = nil
         
     | 
| 
       41 
65 
     | 
    
         
             
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
              
         
     | 
| 
      
 67 
     | 
    
         
            +
                #
         
     | 
| 
      
 68 
     | 
    
         
            +
                # Show proper name for type
         
     | 
| 
      
 69 
     | 
    
         
            +
                def type_name
         
     | 
| 
      
 70 
     | 
    
         
            +
                  TYPE_NAMES[na_type][0]
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
       42 
72 
     | 
    
         
             
              end
         
     | 
| 
       43 
73 
     | 
    
         
             
            end
         
     | 
| 
         @@ -31,30 +31,6 @@ module Beanie 
     | 
|
| 
       31 
31 
     | 
    
         
             
              class NominalAccountCategory < Api
         
     | 
| 
       32 
32 
     | 
    
         
             
                attr_accessor :id, :na_type, :name, :parent_category_id
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                NA_TYPE_FIXED_ASSETS = 0
         
     | 
| 
       35 
     | 
    
         
            -
                NA_TYPE_CURRENT_ASSETS = 1
         
     | 
| 
       36 
     | 
    
         
            -
                NA_TYPE_CURRENT_LIABILITIES = 2
         
     | 
| 
       37 
     | 
    
         
            -
                NA_TYPE_NON_CURRENT_LIABILITIES = 3
         
     | 
| 
       38 
     | 
    
         
            -
                NA_TYPE_RESERVES = 4
         
     | 
| 
       39 
     | 
    
         
            -
                NA_TYPE_INCOME = 5
         
     | 
| 
       40 
     | 
    
         
            -
                NA_TYPE_DIRECT_COSTS = 6
         
     | 
| 
       41 
     | 
    
         
            -
                NA_TYPE_EXPENSE = 7
         
     | 
| 
       42 
     | 
    
         
            -
                NA_TYPE_OTHER_EXPENSE = 8
         
     | 
| 
       43 
     | 
    
         
            -
                NA_TYPE_OTHER_INCOME = 9
         
     | 
| 
       44 
     | 
    
         
            -
              
         
     | 
| 
       45 
     | 
    
         
            -
                NA_TYPE_NAMES = [
         
     | 
| 
       46 
     | 
    
         
            -
                  ["Fixed Assets", NA_TYPE_FIXED_ASSETS],
         
     | 
| 
       47 
     | 
    
         
            -
                  ["Current Assets", NA_TYPE_CURRENT_ASSETS],
         
     | 
| 
       48 
     | 
    
         
            -
                  ["Current Liabilities", NA_TYPE_CURRENT_LIABILITIES],
         
     | 
| 
       49 
     | 
    
         
            -
                  ["Non-Current Liabilities", NA_TYPE_NON_CURRENT_LIABILITIES],
         
     | 
| 
       50 
     | 
    
         
            -
                  ["Reserves", NA_TYPE_RESERVES],
         
     | 
| 
       51 
     | 
    
         
            -
                  ["Income", NA_TYPE_INCOME],
         
     | 
| 
       52 
     | 
    
         
            -
                  ["Direct Costs", NA_TYPE_DIRECT_COSTS],
         
     | 
| 
       53 
     | 
    
         
            -
                  ["Expense", NA_TYPE_EXPENSE],
         
     | 
| 
       54 
     | 
    
         
            -
                  ["Other Expense", NA_TYPE_OTHER_EXPENSE],
         
     | 
| 
       55 
     | 
    
         
            -
                  ["Other Income", NA_TYPE_OTHER_INCOME]
         
     | 
| 
       56 
     | 
    
         
            -
                ].freeze
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
34 
     | 
    
         
             
                #
         
     | 
| 
       59 
35 
     | 
    
         
             
                # Initialize instance variables
         
     | 
| 
       60 
36 
     | 
    
         
             
                def initialize
         
     | 
| 
         @@ -66,8 +42,8 @@ module Beanie 
     | 
|
| 
       66 
42 
     | 
    
         | 
| 
       67 
43 
     | 
    
         
             
                #
         
     | 
| 
       68 
44 
     | 
    
         
             
                # Show proper name for type
         
     | 
| 
       69 
     | 
    
         
            -
                def  
     | 
| 
       70 
     | 
    
         
            -
                   
     | 
| 
      
 45 
     | 
    
         
            +
                def type_name
         
     | 
| 
      
 46 
     | 
    
         
            +
                  NominalAccount::TYPE_NAMES[na_type][0]
         
     | 
| 
       71 
47 
     | 
    
         
             
                end
         
     | 
| 
       72 
48 
     | 
    
         
             
              end
         
     | 
| 
       73 
49 
     | 
    
         
             
            end
         
     | 
    
        data/lib/beanie/product.rb
    CHANGED
    
    | 
         @@ -29,7 +29,7 @@ 
     | 
|
| 
       29 
29 
     | 
    
         
             
            #
         
     | 
| 
       30 
30 
     | 
    
         
             
            module Beanie
         
     | 
| 
       31 
31 
     | 
    
         
             
              class Product < Api
         
     | 
| 
       32 
     | 
    
         
            -
                attr_accessor :id, :description, :name, : 
     | 
| 
      
 32 
     | 
    
         
            +
                attr_accessor :id, :description, :name, :code, :is_service
         
     | 
| 
       33 
33 
     | 
    
         
             
                attr_accessor :nominal_account_id, :product_category_id, :unit_of_measure
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
                #
         
     | 
| 
         @@ -38,7 +38,7 @@ module Beanie 
     | 
|
| 
       38 
38 
     | 
    
         
             
                  @id = nil
         
     | 
| 
       39 
39 
     | 
    
         
             
                  @description = nil
         
     | 
| 
       40 
40 
     | 
    
         
             
                  @name = nil
         
     | 
| 
       41 
     | 
    
         
            -
                  @ 
     | 
| 
      
 41 
     | 
    
         
            +
                  @code = nil
         
     | 
| 
       42 
42 
     | 
    
         
             
                  @is_service = nil
         
     | 
| 
       43 
43 
     | 
    
         
             
                  @nominal_account_id = nil
         
     | 
| 
       44 
44 
     | 
    
         
             
                  @product_category_id = nil
         
     | 
| 
         @@ -46,7 +46,6 @@ module Beanie 
     | 
|
| 
       46 
46 
     | 
    
         
             
                end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
                def self.find_by_name(name)
         
     | 
| 
       49 
     | 
    
         
            -
                  puts "Find by name: #{name}"
         
     | 
| 
       50 
49 
     | 
    
         
             
                  Beanie.find("products", "name", name)
         
     | 
| 
       51 
50 
     | 
    
         
             
                end
         
     | 
| 
       52 
51 
     | 
    
         
             
              end
         
     | 
| 
         @@ -43,20 +43,25 @@ module Beanie 
     | 
|
| 
       43 
43 
     | 
    
         
             
                  @sales_order_id = nil
         
     | 
| 
       44 
44 
     | 
    
         
             
                  @bill_of_material_id = nil
         
     | 
| 
       45 
45 
     | 
    
         
             
                  @work_centre_group_id = nil
         
     | 
| 
      
 46 
     | 
    
         
            +
                  @_private_data = nil
         
     | 
| 
       46 
47 
     | 
    
         
             
                end
         
     | 
| 
       47 
48 
     | 
    
         | 
| 
       48 
49 
     | 
    
         
             
                #
         
     | 
| 
       49 
50 
     | 
    
         
             
                # Get the private data
         
     | 
| 
       50 
51 
     | 
    
         
             
                def private_data
         
     | 
| 
       51 
     | 
    
         
            -
                   
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
                  unless @_private_data
         
     | 
| 
      
 53 
     | 
    
         
            +
                    response = ProductionOrder.get(:url => "/production_orders/#{@id}/private_data")
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @_private_data = response["data"]
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
                  return @_private_data
         
     | 
| 
       53 
57 
     | 
    
         
             
                end
         
     | 
| 
       54 
58 
     | 
    
         | 
| 
       55 
59 
     | 
    
         
             
                #
         
     | 
| 
       56 
60 
     | 
    
         
             
                # Update/set the private data
         
     | 
| 
       57 
61 
     | 
    
         
             
                def private_data=(data)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  @_private_data = data
         
     | 
| 
       58 
63 
     | 
    
         
             
                  pdata = {:data => data}
         
     | 
| 
       59 
     | 
    
         
            -
                   
     | 
| 
      
 64 
     | 
    
         
            +
                  ProductionOrder.post(pdata, :url => "/production_orders/#{@id}/private_data")
         
     | 
| 
       60 
65 
     | 
    
         
             
                end
         
     | 
| 
       61 
66 
     | 
    
         | 
| 
       62 
67 
     | 
    
         
             
                #
         
     | 
    
        data/lib/beanie/version.rb
    CHANGED
    
    
    
        data/lib/beanie/work_centre.rb
    CHANGED
    
    | 
         @@ -29,18 +29,41 @@ 
     | 
|
| 
       29 
29 
     | 
    
         
             
            #
         
     | 
| 
       30 
30 
     | 
    
         
             
            module Beanie
         
     | 
| 
       31 
31 
     | 
    
         
             
              class WorkCentre < Api
         
     | 
| 
       32 
     | 
    
         
            -
                attr_accessor :id, :name, :location, :description, :work_centre_group_id
         
     | 
| 
      
 32 
     | 
    
         
            +
                attr_accessor :id, :name, :state, :location, :description, :work_centre_group_id
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                STATE_UNKNOWN = 0
         
     | 
| 
      
 35 
     | 
    
         
            +
                STATE_MAINTENANCE = 1
         
     | 
| 
      
 36 
     | 
    
         
            +
                STATE_OFFLINE = 2
         
     | 
| 
      
 37 
     | 
    
         
            +
                STATE_READY = 3
         
     | 
| 
      
 38 
     | 
    
         
            +
                STATE_BUSY = 4
         
     | 
| 
      
 39 
     | 
    
         
            +
                STATE_DONE = 5
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                STATE_NAMES = [
         
     | 
| 
      
 42 
     | 
    
         
            +
                  ["Unknown State", STATE_UNKNOWN],
         
     | 
| 
      
 43 
     | 
    
         
            +
                  ["Maintenance Mode", STATE_MAINTENANCE],
         
     | 
| 
      
 44 
     | 
    
         
            +
                  ["Offline (Unavailable)", STATE_OFFLINE],
         
     | 
| 
      
 45 
     | 
    
         
            +
                  ["Ready for Work", STATE_READY],
         
     | 
| 
      
 46 
     | 
    
         
            +
                  ["Working (Busy)", STATE_BUSY],
         
     | 
| 
      
 47 
     | 
    
         
            +
                  ["Work Complete", STATE_DONE]
         
     | 
| 
      
 48 
     | 
    
         
            +
                ].freeze
         
     | 
| 
       33 
49 
     | 
    
         | 
| 
       34 
50 
     | 
    
         
             
                #
         
     | 
| 
       35 
51 
     | 
    
         
             
                # Initialize instance variables
         
     | 
| 
       36 
52 
     | 
    
         
             
                def initialize
         
     | 
| 
       37 
53 
     | 
    
         
             
                  @id = nil
         
     | 
| 
       38 
54 
     | 
    
         
             
                  @name = nil
         
     | 
| 
      
 55 
     | 
    
         
            +
                  @state = nil
         
     | 
| 
       39 
56 
     | 
    
         
             
                  @location = nil
         
     | 
| 
       40 
57 
     | 
    
         
             
                  @description = nil
         
     | 
| 
       41 
58 
     | 
    
         
             
                  @work_centre_group_id = nil
         
     | 
| 
       42 
59 
     | 
    
         
             
                end
         
     | 
| 
       43 
60 
     | 
    
         | 
| 
      
 61 
     | 
    
         
            +
                #
         
     | 
| 
      
 62 
     | 
    
         
            +
                # State name
         
     | 
| 
      
 63 
     | 
    
         
            +
                def state_name
         
     | 
| 
      
 64 
     | 
    
         
            +
                  STATE_NAMES[@state][0]
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
       44 
67 
     | 
    
         
             
                #
         
     | 
| 
       45 
68 
     | 
    
         
             
                # Get the private data
         
     | 
| 
       46 
69 
     | 
    
         
             
                def private_data
         
     | 
| 
         @@ -58,9 +81,12 @@ module Beanie 
     | 
|
| 
       58 
81 
     | 
    
         
             
                #
         
     | 
| 
       59 
82 
     | 
    
         
             
                # Construct the path a little differently...
         
     | 
| 
       60 
83 
     | 
    
         
             
                def construct_path(opts = {})
         
     | 
| 
       61 
     | 
    
         
            -
                   
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
      
 84 
     | 
    
         
            +
                  if opts[:work_centre_group_id]
         
     | 
| 
      
 85 
     | 
    
         
            +
                    path = "/work_centre_groups/#{opts[:work_centre_group_id]}/work_centres"
         
     | 
| 
      
 86 
     | 
    
         
            +
                    opts.delete(:work_centre_group_id)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  else
         
     | 
| 
      
 88 
     | 
    
         
            +
                    path = "/work_centres"
         
     | 
| 
      
 89 
     | 
    
         
            +
                  end
         
     | 
| 
       64 
90 
     | 
    
         
             
                  path
         
     | 
| 
       65 
91 
     | 
    
         
             
                end
         
     | 
| 
       66 
92 
     | 
    
         
             
              end
         
     | 
    
        data/lib/beanie.rb
    CHANGED
    
    | 
         @@ -28,7 +28,7 @@ 
     | 
|
| 
       28 
28 
     | 
    
         
             
            # POSSIBILITY OF SUCH DAMAGE.
         
     | 
| 
       29 
29 
     | 
    
         
             
            #
         
     | 
| 
       30 
30 
     | 
    
         
             
            # Ruby bindings for the Beanie API
         
     | 
| 
       31 
     | 
    
         
            -
            # Docs at http://bean.ie/ 
     | 
| 
      
 31 
     | 
    
         
            +
            # Docs at http://bean.ie/help/api/ruby
         
     | 
| 
       32 
32 
     | 
    
         
             
            require 'rest-client'
         
     | 
| 
       33 
33 
     | 
    
         
             
            require 'json'
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
         @@ -105,13 +105,12 @@ module Beanie 
     | 
|
| 
       105 
105 
     | 
    
         
             
                                                  'Set your API Key using "Beanie.api_key = <API-KEY>". ' \
         
     | 
| 
       106 
106 
     | 
    
         
             
                                                  'Set your Secret Key using "Beanie.secret_key = <SECRET>". ' \
         
     | 
| 
       107 
107 
     | 
    
         
             
                                                  'You can generate API keys from the Beanie web interface. ' \
         
     | 
| 
       108 
     | 
    
         
            -
                                                  'See https://bean.ie/ 
     | 
| 
       109 
     | 
    
         
            -
                                                  'for further assistance.')
         
     | 
| 
      
 108 
     | 
    
         
            +
                                                  'See https://bean.ie/help/api/key for details or email ' \
         
     | 
| 
      
 109 
     | 
    
         
            +
                                                  'support@bean.ie for further assistance.')
         
     | 
| 
       110 
110 
     | 
    
         
             
                  end
         
     | 
| 
       111 
111 
     | 
    
         
             
                  url = "#{@base_uri}/api/authenticate"
         
     | 
| 
       112 
112 
     | 
    
         
             
                  data = {:api_key => @api_key, :secret_key => @secret_key}
         
     | 
| 
       113 
113 
     | 
    
         
             
                  response = RestClient.post(url, data.to_json, :content_type => :json, :accept => :json)
         
     | 
| 
       114 
     | 
    
         
            -
                  puts "Token response: #{response.code} (data: #{response.body})"
         
     | 
| 
       115 
114 
     | 
    
         
             
                  raise AuthenticationError.new('Authentication failure.') unless response.code == 202
         
     | 
| 
       116 
115 
     | 
    
         
             
                  data = JSON.parse(response.body)
         
     | 
| 
       117 
116 
     | 
    
         
             
                  @@token = data['token']
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: beanie
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Dermot Tynan
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-03-07 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -129,7 +129,7 @@ files: 
     | 
|
| 
       129 
129 
     | 
    
         
             
            - lib/beanie/version.rb
         
     | 
| 
       130 
130 
     | 
    
         
             
            - lib/beanie/work_centre.rb
         
     | 
| 
       131 
131 
     | 
    
         
             
            - lib/beanie/work_centre_group.rb
         
     | 
| 
       132 
     | 
    
         
            -
            homepage: https://bean.ie/ 
     | 
| 
      
 132 
     | 
    
         
            +
            homepage: https://bean.ie/help/api/ruby
         
     | 
| 
       133 
133 
     | 
    
         
             
            licenses:
         
     | 
| 
       134 
134 
     | 
    
         
             
            - MIT
         
     | 
| 
       135 
135 
     | 
    
         
             
            metadata: {}
         
     |