Skip to content

infopark/webcrm_sdk

Repository files navigation

JustRelate WebCRM SDK

Gem Version

JustRelate WebCRM is a cloud-based CRM. The JustRelate WebCRM SDK makes CRM content available to your Ruby application. It is a client of the JustRelate WebCRM REST API v2.

This SDK lets you access and manipulate accounts and contacts, for example, perform searches, etc.

Installation

Add infopark_webcrm_sdk to your Gemfile:

gem 'infopark_webcrm_sdk'

Install the gem with Bundler:

bundle install

Configuration

require 'infopark_webcrm_sdk'

Crm.configure do |config|
  config.tenant  = 'my_tenant'
  config.login   = 'my_login'
  config.api_key = 'my_api_key'
end

Documentation

The documentation is available at RubyDoc.info.

Example Usage

The JustRelate WebCRM SDK provides the following JustRelate WebCRM resources to your Ruby application:

  • {Crm::Account}
  • {Crm::Activity}
  • {Crm::Collection}
  • {Crm::Contact}
  • {Crm::EventContact}
  • {Crm::Event}
  • {Crm::Mailing}
  • {Crm::MailingDelivery}
  • {Crm::TemplateSet}
  • {Crm::Type}

Most of these classes have methods such as {Crm::Core::Mixins::Findable::ClassMethods#find find}, {Crm::Core::Mixins::Modifiable::ClassMethods#create create}, {Crm::Core::Mixins::Modifiable#update update}, {Crm::Core::Mixins::Searchable::ClassMethods#query query}, and {Crm::Core::Mixins::Searchable::ClassMethods#where where}.

Creating a Contact

contact = Crm::Contact.create({
  first_name: 'John',
  last_name: 'Smith',
  language: 'en',
  locality: 'New York',
})
# => Crm::Contact

contact.first_name
# => 'John'

contact.id
# => 'e70a7123f499c5e0e9972ab4dbfb8fe3'

Fetching and Updating a Contact

# Retrieve the contact by ID
contact = Crm::Contact.find('e70a7123f499c5e0e9972ab4dbfb8fe3')
# => Crm::Contact

contact.last_name
# => 'Smith'

contact.locality
# => 'New York'

# Change this contact's locality
contact.update({locality: 'Boston'})
# => Crm::Contact

contact.last_name
# => 'Smith'

contact.locality
# => 'Boston'

Searching for Contacts

Crm::Contact.where(:login, :equals, 'root').first
# => Crm::Contact

Crm::Contact.where(:locality, :equals, 'Boston').
  and(:last_name, :contains_word_prefixes, 'S').
  sort_by(:last_name).
  sort_order(:desc).
  limit(2).
  map(&:last_name)
# => ['Smith', 'Simpson']

License

Copyright (c) 2015 - 2024 JustRelate Group GmbH.

This software can be used and modified in accordance with the MIT license. Please refer to LICENSE for details.