/dynamics_crm

Ruby library for interacting with Microsoft Dynamics CRM SOAP API

Primary LanguageRubyMIT LicenseMIT

DynamicsCRM

Build Status

Ruby library for accessing Microsoft Dynamics CRM Online 2011/2013 via their SOAP API.

Installation

Add this line to your application's Gemfile:

gem 'dynamics_crm'

And then execute:

$ bundle

Or install it yourself as:

$ gem install dynamics_crm

Usage

Username/Password authentication

client = DynamicsCRM::Client.new({organization_name: "orgname"})
client.authenticate('user@orgname.onmicrosoft.com', 'password')

retrieve

client.retrieve('account', '53291AAB-4A9A-E311-B097-6C3BE5A8DD60')
# => #<DynamicsCRM::XML::Entity ... >

retrieve_multiple

client.retrieve_multiple('account', [["name", "Equal", "Test Account"]])
# => [#<DynamicsCRM::XML::Entity ... >]

client.retrieve_multiple('account', [["name", "Equal", "Test Account"], ["Name, "CreatedBy"]])
# => [#<DynamicsCRM::XML::Entity ... >]

create

# Add a new account
client.create('account', name: 'Foobar Inc.')
# => {id: '53291AAB-4A9A-E311-B097-6C3BE5A8DD60'}

# Add a new contact
client.create('contact', firstname: 'John', lastname: 'Doe', emailaddress1: "johndoe@mydomain.com")
# => {id: '71ef2416-50f7-e311-93fc-6c3be5a8c054'}

update

# Update the Account with id '53291AAB-4A9A-E311-B097-6C3BE5A8DD60'
client.update('account', '53291AAB-4A9A-E311-B097-6C3BE5A8DD60', name: 'Whizbang Corp')
# => {}

delete

# Delete the Account with id '53291AAB-4A9A-E311-B097-6C3BE5A8DD60'
client.delete('account', '53291AAB-4A9A-E311-B097-6C3BE5A8DD60')
# => {}

retrieve_all_entities

# get the list of organization entities
client.retrieve_all_entities
# => [#<DynamicsCRM::Metadata::EntityMetadata>, ...]

retrieve_entity

# get the entity metadata for the account object
client.retrieve_entity('account')
# => DynamicsCRM::Metadata::EntityMetadata

retrieve_attribute

# get AttributeMetadata for 'name' field on the account object
client.retrieve_attribute('account', 'name')
# => [#<DynamicsCRM::Metadata::AttributeMetadata>, ...]

associate a contact to an account

contacts = [ DynamicsCRM::XML::EntityReference.new("contact", contact["id"])]
client.associate("account", account["id"], "contact_customer_accounts", contacts)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request