Giter VIP home page Giter VIP logo

active_force's People

Contributors

bradstewart avatar danielpk avatar danolson avatar eloyesp avatar julioalucero avatar lmhsjackson avatar simi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

active_force's Issues

Use with geocoder or searchkick ?

Hello !

Do you know if there is a way to use your gem with the geocoder or searchkick gem ?

I'm trying to find Account records near to a latitude/longitude.

Do you have any idea to help me ?

Thanks !

Add support for upsert

Adding support for upsert would save an API call in some use cases. It should maybe be called find_or_create and follow ActiveRecord semantics. Restforce supports upsert.

Is anyone else interested? Was this already discussed?

Using separate Restforce sessions using OAuth

I have an application where each user authenticates using omniauth to Salesforce to get their own Restforce client for requests to Salesforce.

What's the best way to override the active_force.SObject.client to allow for this to be used, rather than setting up a new Restforce connection that uses application wide environment variables?

use ActiveSupport::HashWithIndifferentAccess for field mappings

To prevent stuff like below from happening:

https://www.dropbox.com/s/32yu3nnrd8pooqa/Screenshot%202015-11-12%2010.04.52.png?dl=0

Which prevents save/create of models if the user makes mistake of specifying field names as strings instead of symbols.

It will require activesupport as a dependency, however since most people using this gem will already be using rails, I don't see any reason not to add that dependency. Also if you add active model as a dependency as per #95 , dependency will be met anyways. Im happy to PR if you will accept.

Add `Query#includes`

In the case of the following class:

class Account < ActiveForce::SObject
    field :id, from: 'Id'
    field :thing_id, from: 'Thing__c'

    belongs_to :thing
end

it would be nice to be able to send a single API request which also build the object in memory to include the relations, similarly to ActiveRecord, like so:

pry(main)> Account.includes(:thing).where(' Id != NULL').to_s
=> "SELECT Id, Thing__c, Thing__r.Id, Thing__r.OtherThingFields FROM Account WHERE Id != NULL"

pry(main)> account = Account.includes(:thing).first
=> #<Account id: "001V000000EwBR0IAN", thing_id: "00580000005sD0hAAE">

pry(main)> a.thing
=> #<Thing id: "00580000005sD0hAAE"> # loaded without separate API request.

Model generator fails for camel case standard types

Generating a model from a camel case standard type generates incorrect filenames and class names.

i.e
SiteHistory creates the following

sitehistory.rb

class Sitehistory < ActiveForce::SObject
end

Should instead be the following

site_history.rb

class SiteHistory < ActiveForce::SObject
end

Trying to update a non-declared field should fail loudly.

Given:

class Case < ActiveForce::SObject
  field :id, from: 'Id'
end

kase = Case.find 123

kase.update_attributes! foo: 'bar' # This should fail loudly.

When trying to update an attribute not declared, ActiveForce should fail loudly. Instead it just ignores the parameter, without even sending it to Salesforce API (which would at least complain).

Add `Query#select` method

It would be very useful to be able to do Account.select(:id, 'Name').all and have it only return the Id and Name columns.

Can't access to Restforce::Mash

Hello all !

I don't know why but i'm not able to access to latitude and longitude include in location field :

undefined method `latitude' for "#<Restforce::Mash latitude=43.0082399 longitude=-88.0568406>":String

Extracted source (around line #13):
    if @accounts
      @hash = Gmaps4rails.build_markers(@accounts) do |account, marker|
        raise account.location.latitude.inspect
        # marker.lat account.location.latitude
        # marker.lng account.location.longitude
        marker.infowindow account.name

Could you help me to understand why ?

Don't repeat queries for associations

If I have a relationship defined like so:

 class Lead < ActiveForce::SObject
    field :business_partner_id, from: 'Business_Partner_Id__c'
    belongs_to :business_partner, model: Account, foreign_key: :business_partner_id
end

It would be nice if there wasn't an API call for every @lead.business_partner call, and instead it only needed to be loaded once.

Allow ranges in `#where` values

Not sure what the solution is, but it would be cool if this worked.

Currently, this happens.

[1] pry(main)> Opportunity.where(id: 1..3).to_s
=> "SELECT Id FROM Opportunity WHERE Id = 1..3"

Generator

Remove field :id generation
Remove requiring sobject at top of the file

Need test for SObject.

Should test the value transformation when saving to SFDC. Example:

class Led < SObject
   field :colors,  as: :multi_picklist
end

some_led.colors = ['Red', 'Blue']

Client should receive query with "Colors__c = 'Red;Blue'"

currently it's not working because read_value isn't being called when creating/updating

Add `SObject#primary_key`

It would be useful to be able to reference a table's primary key with a class method. Although this is usually just 'Id', in rare cases it may be different, so it would also be nice to have a setter for this on the class level.

Dates or Times specified in conditional associations are not lazily evaluated

From the README:

class Account < ActiveForce::SObject
  has_many :medications,
    where: "Discontinued__c > #{ Date.today.strftime("%Y-%m-%d") }" \
           "OR Discontinued__c = NULL"
end

This Date.today will only be evaluated when the account class is loaded, and it will not be reevaluated when called: (account.medications). If I boot a Rails app with this code on a Monday, and then on Wednesday I call Account.find('someid').medications, the query will use Monday's date in the where clause.

Model callbacks.

I would like to have a class method to define some other methods to be called after or before the update, create or save actions.

class Account < ActiveForce::SObject
  before_save :set_default_values

  private

  def set_default_values
    self.some_field = 0
  end

end

Eager loading

  • Including a standard type in the query shouldn't add "__r"
  • Currently the retrieved nested object isn't being set in the association cache

Remove active attr.

We are currently using a patched version of ActiveAttr, but I think that it was a bad design decision, I'm almost sure that we should remove this dependency and use ActiveModel using these instructions instead.

I think that this is important as it will simplify the gem and will make it easier to maintain and understand.

Default 'Id' field on all models.

The 'Id' field is a standard field on all Salesforce Objects, so it seems redundant to specify it in each class declaration with:

class Lead < ActiveForce::SObject
  field :id, from: 'Id'
end

Allow `Query#where` to accept a hash or array of arguments.

It would be nice to be able to just supply a Hash or array of arguments to be 'and'-ed, similar to ActiveRecord.
For example:

class Lead < ActiveForce::SObject
    field :id, from: 'Id'
    field :name, from: 'Name'
    field :title, from: 'Title'
end

allows

pry(main)> Lead.where("Name = ? AND Title = ?", 'Jim Jones', 'Mr.').to_s
=> "SELECT Id, Name, Title FROM Lead WHERE Name ='Jim Jones' AND Title ='Mr.'"

or

pry(main)> Lead.where(name: 'Jim Jones', title:'Mr.').to_s
=> "SELECT Id, Name, Title FROM Lead WHERE Name ='Jim Jones' AND Title ='Mr.'"

An added bonus would be if this would also guard against any potential SOQL Injection issues, such as:

pry(main)> params = {id: "'' OR Id != null"}
pry(main)> Lead.where("Id = ?", params[:id]).to_s
=> "SELECT Id, Name, Title FROM Lead WHERE Id = ''''' OR Id != null'"

Support for Rails 5

I would like to know it this gem can be used on Rails 5 projects. Someone have experience working with this gem on Rails 5 projects?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.