tedkulp-freshbooks.rb 3.0.19 → 3.0.20

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -35,8 +35,7 @@ This work is distributed under the MIT License. Use/modify the code however you
35
35
 
36
36
  = Download
37
37
 
38
- gem sources -a http://gems.github.com
39
- sudo gem install bcurren-freshbooks.rb
38
+ sudo gem install tedkulp-freshbooks.rb
40
39
 
41
40
  = Credits
42
41
 
data/lib/freshbooks.rb CHANGED
@@ -60,7 +60,7 @@ require 'logger'
60
60
  #
61
61
  #==============================================================================
62
62
  module FreshBooks
63
- VERSION = '3.0.19' # Gem version
63
+ VERSION = '3.0.20' # Gem version
64
64
  API_VERSION = '2.1' # FreshBooks API version
65
65
  SERVICE_URL = "/api/#{API_VERSION}/xml-in"
66
66
 
@@ -5,6 +5,10 @@ module FreshBooks
5
5
  class Base
6
6
  include FreshBooks::Schema::Mixin
7
7
 
8
+ def initialize(args = {})
9
+ args.each_pair {|k, v| send("#{k}=", v)}
10
+ end
11
+
8
12
  @@connection = nil
9
13
  def self.connection
10
14
  @@connection
@@ -32,6 +32,11 @@ module FreshBooks
32
32
  Response.new(result)
33
33
  end
34
34
 
35
+ def direct_post(xml)
36
+ result = post(xml)
37
+ Response.new(result)
38
+ end
39
+
35
40
  def start_session(&block)
36
41
  @connection = obtain_connection if @start_session_count == 0
37
42
  @start_session_count = @start_session_count + 1
@@ -1,5 +1,8 @@
1
1
  module FreshBooks
2
2
  class Invoice < FreshBooks::Base
3
+
4
+
5
+
3
6
  define_schema do |s|
4
7
  s.fixnum :invoice_id, :client_id, :po_number
5
8
  s.fixnum :recurring_id, :read_only => true
@@ -9,7 +12,7 @@ module FreshBooks
9
12
  s.date_time :updated, :read_only => true
10
13
  s.array :lines
11
14
  s.object :links, :read_only => true
12
- s.string :number, :organization, :status, :notes, :terms, :first_name, :last_name
15
+ s.string :number, :organization, :status, :notes, :terms, :first_name, :last_name, :currency_code
13
16
  s.string :p_street1, :p_street2, :p_city, :p_state, :p_country, :p_code
14
17
  s.string :return_uri
15
18
  end
@@ -1,5 +1,6 @@
1
1
  module FreshBooks
2
2
  class Line < FreshBooks::Base
3
+
3
4
  define_schema do |s|
4
5
  s.string :name, :description, :tax1_name, :tax2_name
5
6
  s.float :unit_cost, :tax1_percent, :tax2_percent
data/test/test_base.rb CHANGED
@@ -66,6 +66,36 @@ class TestBase < Test::Unit::TestCase
66
66
  assert xml_out.include?("<my_lines><my_line><description>description</description></my_line></my_lines>")
67
67
  end
68
68
 
69
+ def test_create_objects_with_initializer_arguments
70
+ invoice_1 = FreshBooks::Invoice.new
71
+ invoice_1.client_id = 1
72
+ invoice_1.lines = [FreshBooks::Line.new, FreshBooks::Line.new]
73
+ invoice_1.lines[0].name = "Awesomeness"
74
+ invoice_1.lines[0].unit_cost = 9999
75
+ invoice_1.lines[0].quantity = 42
76
+ invoice_1.lines[1].name = "Ninja skills"
77
+ invoice_1.lines[1].unit_cost = 349
78
+ invoice_1.lines[1].quantity = 100
79
+
80
+ invoice_2 = FreshBooks::Invoice.new(
81
+ :client_id => 1,
82
+ :lines => [
83
+ FreshBooks::Line.new(
84
+ :name => "Awesomeness",
85
+ :unit_cost => 9999,
86
+ :quantity => 42
87
+ ),
88
+ FreshBooks::Line.new(
89
+ :name => "Ninja skills",
90
+ :unit_cost => 349,
91
+ :quantity => 100
92
+ )
93
+ ]
94
+ )
95
+
96
+ assert_equal invoice_1.to_xml, invoice_2.to_xml
97
+ end
98
+
69
99
  end
70
100
 
71
101
  module FreshBooks
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tedkulp-freshbooks.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.19
4
+ version: 3.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Curren