README.md in netsuite-0.0.49 vs README.md in netsuite-0.0.50
- old
+ new
@@ -1,10 +1,11 @@
# NetSuite Ruby SuiteTalk Gem
* This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API. Wow, that is a mouthful.
* The gem does not cover the entire API, only the subset that we have found useful to cover so far.
-* Extending the wrapper is pretty simple. See below for an example.
+* Extending the wrapper is pretty simple. Check out the [contribution help doc](https://github.com/RevolutionPrep/netsuite/wiki/Contributing-to-the-Supported-NetSuite-API)
+* NetSuite development is overall a pretty poor experience. We have a list of [NetSuite Development Resources](https://github.com/RevolutionPrep/netsuite/wiki/NetSuite-Development-Resources) that might make things a bit less painful.
## Installation
Add this line to your application's Gemfile:
@@ -22,11 +23,11 @@
## Testing
Before contributing a patch make sure all existing tests pass.
```
-git clone git://github.com/iloveitaly/netsuite.git
+git clone git://github.com/RevolutionPrep/netsuite.git
cd netsuite
bundle
bundle exec rspec
```
## Usage
@@ -34,116 +35,59 @@
### Configuration
```ruby
NetSuite.configure do
reset!
+ # optional, defaults to 2011_2
api_version '2012_1'
- # specify full wsdl URL for sandbox / production switching
+ # optionally specify full wsdl URL (to switch to sandbox, for example)
wsdl "https://webservices.sandbox.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl"
+ # or specify the sandbox flag if you don't want to deal with specifying a full URL
+ sandbox true
+
+ # often the netsuite servers will hang which would cause a timeout exception to be raised
+ # if you don't mind waiting (e.g. processing NS via DJ), increasing the timeout should fix the issue
+ read_timeout 100000
+
+ # you can specify a file or file descriptor to send the log output to (defaults to STDOUT)
+ log File.join(Rails.root, 'log/netsuite.log')
+
# login information
- email 'email@domain.com'
- password 'password'
+ email 'email@domain.com'
+ password 'password'
account '12345'
role 1111
end
```
-### Customer
+### Examples
-* Initializing a customer can be done using a hash of attributes.
+```ruby
+# retrieve a customer
+customer = NetSuite::Records::Customer.get(:internal_id => 4)
+customer.is_person
-### Get
+# or
+NetSuite::Records::Customer.get(4).is_person
-* Retrieves the customer by internalId.
+# randomly assign a task
+customer_support_reps = [12345, 12346]
- ```Ruby
- customer = NetSuite::Records::Customer.get(:internal_id => 4)
- # => #<NetSuite::Records::Customer:0x1042f59b8>
- customer.is_person
- # => true
-
- # or
- NetSuite::Records::Customer.get(4).is_person
- ```
+task = NetSuite::Records::Task.new(
+ :title => 'Take Care of a Customer',
+ :assigned => NetSuite::Records::RecordRef.new(customer_support_reps.sample),
+ :due_date => DateTime.now + 1,
+ :message => "Take care of this"
+)
-## Additions
+task.add
-* Please submit a pull request for any models or actions that you would like to be included. The API is quite large and so we will necessarily not cover all of it.
-* Records should go into the `lib/netsuite/records/` directory.
-* Actions should be placed in their respective subdirectory under `lib/netsuite/actions`.
-* Example:
+# this will only work on OS X, open a browser to the record that was just created
+`open https://system.sandbox.netsuite.com/app/crm/calendar/task.nl?id=#{invoice.internal_id}`
- ```Ruby
- # lib/netsuite/actions/customer/add.rb
+task.update :message => 'New Message'
+```
- module NetSuite
- module Actions
- module Customer
- class Add
- def initialize(attributes = {})
- @attributes = attributes
- end
- def self.call(attributes)
- new(attributes).call
- end
-
- def call
- response = NetSuite::Configuration.connection.request :add do
- soap.header = NetSuite::Configuration.auth_header
- soap.body = {
- :entityId => @attributes[:entity_id],
- :companyName => @attributes[:company_name],
- :unsubscribe => @attributes[:unsubscribe]
- }
- end
- success = response.to_hash[:add_response][:write_response][:status][:@is_success] == 'true'
- body = response.to_hash[:add_response][:write_response][:base_ref]
- NetSuite::Response.new(:success => success, :body => body)
- end
-
- end
- end
- end
- end
-
- response = NetSuite::Actions::Customer::Add.call(
- :entity_id => 'Shutter Fly',
- :company_name => 'Shutter Fly, Inc.',
- :unsubscribe => false
- ) # => #<NetSuite::Response:0x1041f64b5>
- response.success? # => true
- response.body # => { :internal_id => '979', :type => 'customer' }
- ```
-
-## Gotchas
-
- * The Initialize Action duck-punches the .initialize method on any class that includes it.
- This has not proven to be a issue yet, but should be taken into account when analyzing any
- strange issues with the gem.
- * Some records define a 'class' field. Defining a 'class' field on a record overrides the
- #class and #class= methods for this class. This is very obviously a problem. You can,
- instead, define a 'klass' field that will be turned into 'class' before being submitted
- to the API. The Invoice record has an example of this.
-
-## Contributing
-
-1. Fork it
-2. Create your feature branch (`git checkout -b my-new-feature`)
-3. Write new test and ensure that `bundle exec rspec` doesn't fail
-4. Commit your changes (`git commit -am 'Added some feature'`)
-5. Push to the branch (`git push origin my-new-feature`)
-6. Create new Pull Request
-
-## Fields and RecordRefs
-
-Note that some record attributes are specified as Fields while others are specified as RecordRefs. In some cases
-attributes are actually RecordRefs in the schema, but we indicate them as Fields. Our experience has shown
-this works as long as the attribute is only read from and is not written to. Writing a value for an attribute
-that has been wrongly specified will result in an error. Be careful when initializing objects from other objects --
-they may carry attributes that write to the new object.
-
-As we build up this gem we will replace these inconsistent Fields with RecordRefs. Feel free to contribute new Record
-definitions to help us along.