Mycrm Gem
A library to simplify communication with the MyCrm data service.
Configuration
storage = Redis.new({"host"=>"localhost", "port"=>6379, "namespace"=>"loan-market-platform-development"})
Mycrm.configure do |conf|
conf.base_uri = 'https://api.endopoint.com'
conf.username = 'some-user-name'
conf.password = 'very-secret'
conf.logger = ::Logger.new(STDOUT)
conf.storage = storage
conf.token_storage_expiry = 600 # in seconds default 10 minutes (600)
# it overrides the default domains' values
conf.domains = {
sources: {
lm_contact_us: -9
},
purposes: {
first_home: 17207
},
loan_features:{
other: 16928
},
adviser_sources:{
loan_market_careers_website: 16
},
adviser_types:{
mortgage_broker: 7829
},
other_option:{
other: 36928
}
}
end
Create a new simple lead
lead = Mycrm::Facades::Lead.new
lead.first_name = 'Michael'
lead.last_name = 'Stephens'
lead.email = '[email protected]'
lead.mobile = '0555123457'
lead.home_address = '135 King Street, 2000, Sydney, NSW, Australia'
lead.mobile_validated = true
lead.allocated_broker_id = 858860
lead.source = 'Lm Contact Us'
lead.activity_title = 'Gem Enquiry!'
lead.activity_details = 'I would like to ask...'
lead.create!
Create a new lead with loan application
lead = Mycrm::Facades::LeadApplication.new
lead.first_name = 'Michael'
lead.last_name = 'Stephens'
lead.email = '[email protected]'
lead.mobile = '0555123457'
lead.home_address = '135 King Street, Sydney, 2000, NSW'
lead.mobile_validated = true
lead.allocated_broker_id = 858860
lead.source = 'Lm Contact Us'
lead.settlement_date = "2017-06-06T23:38:18.609Z"
lead.add_purpose 'First Home'
lead.add_feature 'Other'
lead.loan_term = 120
lead.loan_amount = 35000
lead.activity_title = 'Gem Enquiry!'
lead.activity_details = 'I would like to ask...'
lead.create!
Create a new prospect adviser
adviser = Mycrm::Models::Adviser.new
adviser.first_name = 'James'
adviser.last_name = 'Smith'
adviser.email = '[email protected]'
adviser.mobile = '0555123457'
adviser.business_phone = '0405666555'
adviser.business_address = '135 King Street, Sydney, 2000, NSW'
adviser.summary = "I'm looking for job!"
adviser.source = 'Loan Market Careers Website'
adviser.reporting_country = 'Australia'
adviser.type = 'Mortgage Broker'
adviser.create!
Development
Running tests in development
Some of the tests run against the test instance of the actual My CRM API.
To run these locally add a .env.local
file with API_BASE_URI
, API_USERNAME
, and API_PASSWORD
:
API_BASE_URI=https://testapi.nzfsg.co.nz
API_USERNAME=$api-user-email
API_PASSWORD=$api-user-password
Get the propper details off one of the Loan Market developers.