This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

basic rspec and readme

  • Loading branch information...
1 parent efc64e4 commit 5fa50188e3d45a11537d21674c9f5cdeac20f914 @ruckus committed Feb 13, 2012
View
@@ -1,4 +1,3 @@
source 'http://rubygems.org'
-#gem "soap4r", :git => "git://github.com/rubyjedi/soap4r.git"
-gem "virtus"
+gemspec
View
@@ -1,10 +1,42 @@
+PATH
+ remote: .
+ specs:
+ quickeebooks (0.0.1)
+ roxml
+
GEM
remote: http://rubygems.org/
specs:
- virtus (0.2.0)
+ activesupport (3.2.1)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ diff-lcs (1.1.3)
+ i18n (0.6.0)
+ multi_json (1.0.4)
+ nokogiri (1.5.0)
+ rake (0.9.2.2)
+ rcov (0.9.11)
+ roxml (3.3.1)
+ activesupport (>= 2.3.0)
+ nokogiri (>= 1.3.3)
+ rr (1.0.4)
+ rspec (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
+ rspec-mocks (~> 2.0.1)
+ rspec-core (2.0.1)
+ rspec-expectations (2.0.1)
+ diff-lcs (>= 1.1.2)
+ rspec-mocks (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
PLATFORMS
ruby
DEPENDENCIES
- virtus
+ quickeebooks!
+ rake
+ rcov (~> 0.9.8)
+ rr (~> 1.0.2)
+ rspec (~> 2.0.0)
View
@@ -0,0 +1,5 @@
+== Quickeebooks ==
+
+Integration with Quickbooks Online via the Intuit Data Services REST API.
+
+This library facilitates the marshaling of XML responses into Ruby objects.
View
@@ -0,0 +1,17 @@
+require "rubygems"
+require "bundler"
+Bundler.setup
+
+require "rake"
+require "rspec"
+require "rspec/core/rake_task"
+
+$:.unshift File.expand_path("../lib", __FILE__)
+require "quickeebooks"
+
+task :default => :spec
+
+desc "Run all specs"
+Rspec::Core::RakeTask.new(:spec) do |t|
+ t.pattern = 'spec/**/*_spec.rb'
+end
View
@@ -1,19 +0,0 @@
-module Quickbooks
-
- class IntuitType
- include Virtus
- end
-
- class Metadata < IntuitType
- attribute :CreateTime, DateTime
- end
-
- class Customer < IntuitType
- attribute :id, String
- attribute :SyncToken, Integer
- attribute :MetaData, Quickbooks::Metadata
- end
-
-end
-
-#require './quickbooks/customer'
View
@@ -0,0 +1,17 @@
+=begin
+require 'rubygems'
+require 'roxml'
+require './lib/quickbooks'
+xml = File.read("customer.xml")
+d = Quickbooks::Customer.from_xml(xml)
+=end
+
+require 'roxml'
+
+module Quickeebooks
+
+ class IntuitType
+ include ROXML
+ end
+
+end
@@ -0,0 +1,78 @@
+require "quickeebooks"
+require "quickeebooks/meta_data"
+
+module Quickeebooks
+
+ class Customer < IntuitType
+ xml_accessor :id, :from => 'Id'
+ xml_accessor :syncToken, :from => 'SyncToken', :as => Integer
+ xml_accessor :name, :from => 'Name'
+ xml_accessor :meta_data, :from => 'MetaData', :as => Quickeebooks::MetaData
+ end
+
+end
+
+=begin
+<Customer>
+ <Id idDomain="QBO">1</Id>
+ <SyncToken>1</SyncToken>
+ <MetaData>
+ <CreateTime>2011-09-29T15:45:12-07:00</CreateTime>
+ <LastUpdatedTime>2012-01-22T20:35:57-08:00</LastUpdatedTime>
+ </MetaData>
+ <Name>John Doe</Name>
+ <Address>
+ <Line1>123 Main St.</Line1>
+ <Line2>Suite 400</Line2>
+ <City>San Diego</City>
+ <Country>USA</Country>
+ <CountrySubDivisionCode>CA</CountrySubDivisionCode>
+ <PostalCode>96009</PostalCode>
+ <Tag>Billing</Tag>
+ </Address>
+ <Address>
+ <Line1>123 Main St.</Line1>
+ <Line2>Suite 400</Line2>
+ <City>San Diego</City>
+ <Country>USA</Country>
+ <CountrySubDivisionCode>CA</CountrySubDivisionCode>
+ <PostalCode>96009</PostalCode>
+ <Tag>Shipping</Tag>
+ </Address>
+ <Phone>
+ <DeviceType>Primary</DeviceType>
+ <FreeFormNumber>(408) 555-1212</FreeFormNumber>
+ </Phone>
+ <Phone>
+ <DeviceType>Mobile</DeviceType>
+ <FreeFormNumber>(831) 334-0987</FreeFormNumber>
+ </Phone>
+ <WebSite/>
+ <Email>
+ <Address>johndoe@gmail.com</Address>
+ </Email>
+ <GivenName>John</GivenName>
+ <FamilyName>Doe</FamilyName>
+ <DBAName>John's Wine Shop</DBAName>
+ <Notes>
+ <Content>Likes chocolate and horses</Content>
+ </Notes>
+ <CustomField xsi:type="BooleanTypeCustomField">
+ <DefinitionId>Bill With Parent</DefinitionId>
+ <Value>false</Value>
+ </CustomField>
+ <CustomField xsi:type="StringTypeCustomField">
+ <DefinitionId>Resale Number</DefinitionId>
+ <Value>ABC-123</Value>
+ </CustomField>
+ <CustomField xsi:type="StringTypeCustomField">
+ <DefinitionId>Preferred Delivery Method</DefinitionId>
+ <Value>PRINT</Value>
+ </CustomField>
+ <SalesTermId idDomain="QBO">3</SalesTermId>
+ <PaymentMethodId idDomain="QBO">5</PaymentMethodId>
+ <OpenBalance>
+ <Amount>6200</Amount>
+ </OpenBalance>
+</Customer>
+=end
@@ -0,0 +1,10 @@
+require 'quickeebooks'
+require 'time'
+
+module Quickeebooks
+
+ class MetaData < IntuitType
+ xml_accessor :create_time, :from => 'CreateTime', :as => Time
+ xml_accessor :last_updated_time, :from => 'LastUpdatedTime', :as => Time
+ end
+end
@@ -0,0 +1,5 @@
+module Quickeebooks
+
+ VERSION = "0.0.1"
+
+end
View
@@ -0,0 +1,24 @@
+$:.unshift File.expand_path("../lib", __FILE__)
+require "Quickeebooks/version"
+
+Gem::Specification.new do |gem|
+ gem.name = "quickeebooks"
+ gem.version = Quickeebooks::VERSION
+
+ gem.author = "Cody Caughlan"
+ gem.email = "toolbag@gmail.com"
+ gem.homepage = "http://github.com/ruckus/quickeebooks"
+ gem.summary = "REST integration with Quickbooks Online"
+
+ gem.description = gem.summary
+
+ gem.files = Dir["**/*"]#.select { |d| d =~ %r{^(README|bin/|data/|ext/|lib/|spec/|test/)} }
+
+ gem.add_dependency 'roxml'
+
+ gem.add_development_dependency 'rake'
+ #gem.add_development_dependency 'fakefs', '~> 0.2.1'
+ gem.add_development_dependency 'rcov', '~> 0.9.8'
+ gem.add_development_dependency 'rr', '~> 1.0.2'
+ gem.add_development_dependency 'rspec', '~> 2.0.0'
+end
Binary file not shown.
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+require "quickeebooks/customer"
+
+describe "Quickeebooks::Customer" do
+
+ describe "parse customer from XML" do
+ xml = File.read(File.dirname(__FILE__) + "/../xml/customer.xml")
+ customer = Quickeebooks::Customer.from_xml(xml)
+ customer.syncToken.should == 1
+ customer.name.should == "John Doe"
+
+ create_time = Date.civil(2011, 9, 29)
+ customer.meta_data.create_time.year.should == create_time.year
+ end
+
+end
View
@@ -0,0 +1,11 @@
+require "spec_helper"
+require "quickeebooks"
+
+describe Quickeebooks do
+
+ describe "VERSION" do
+ subject { Quickeebooks::VERSION }
+ it { should be_a String }
+ end
+
+end
View
@@ -0,0 +1,20 @@
+require "rubygems"
+require "rspec"
+
+$:.unshift "lib"
+
+def mock_error(subject, message)
+ mock_exit do
+ mock(subject).puts("ERROR: #{message}")
+ yield
+ end
+end
+
+def mock_exit(&block)
+ block.should raise_error(SystemExit)
+end
+
+Rspec.configure do |config|
+ config.color_enabled = true
+ config.mock_with :rr
+end
@@ -1,17 +1,4 @@
-
-module Quickbooks
-
- class Customer < IntuitType
- #attr_accessor :id
- #attr_accessor :syncToken
- #attr_accessor :MetaData
- attribute :id, String
- attribute :syncToken, Integer
- attribute :metaData, QuickBooks::Metadata
- end
-end
-
-=begin
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer>
<Id idDomain="QBO">1</Id>
<SyncToken>1</SyncToken>
@@ -73,5 +60,4 @@ class Customer < IntuitType
<OpenBalance>
<Amount>6200</Amount>
</OpenBalance>
-</Customer>
-=end
+</Customer>
Oops, something went wrong.

0 comments on commit 5fa5018

Please sign in to comment.