0

I am working on an application where one of its functions is to pull mls/rets real estate listing data from SimplyRets. I'm brand new to API integration and I have ran into some issues:

Using ActiveResource I can't get the app to connect. (end up with 401 Unauthorized.) Here's my Model:

class Listing < ActiveResource::Base

  self.site = "https://api.simplyrets.com/properties"
  user = "simplyrets"
  password = "simplyrets"

end

Using the Flexirest gem I'm more lucky. I can connect and have set up routes and a controller that works quite nicely. Heres that Model:

class Listing < Flexirest::Base
    extend ActiveModel::Naming
    include ActiveModel::Conversion
    include ActiveModel::Validations
    base_url Rails.application.config.api_server_url

    username 'simplyrets'
    password 'simplyrets'

    get :all, "/properties"
    get :where, "/properties"
    get :find, "/properties/:id"

end

But, the problem I'm running into with Flexirest is using Ransack (for searching) or really anytime I try to chain a .where to the danged thing. getting this error:

undefined method `search' for Listing:Class

What do I need to do to be able to search this APIs Array? How can I use that arel .where good good? Will ActiveResource do this for me? Can I convert the data I'm pulling from Flexirest to something I can manipulate with a conditional statement?

I hope I explained myself clearly enough. If anyone wants any other code I can edit.

  • I'm the author of Flexirest but don't quite understand what you're doing. The class above helps, but how are you using it? For example, there's no "search" in any of the code you've posted. Happy to help if i can... – Andy Jeffries Mar 21 '18 at 11:34
  • Thanks for the response. You are correct. I had to abandon any idea involving ActiveRecord alongside Flexirest, in favor of sending the search query to the API and getting results that way. I think that I just needed to read though the documentation a few more times. Still using Flexirest! Very great gem! – Colton Hagan Mar 24 '18 at 07:45

1 Answers1

0

I found that using ActiveRecord with a Flexirest object to be a mistake, from my searches I've found that for my project I would be better off sending a GET request with a query. If anyone needs some code to show how I did this, I will happily supply it, however, this was just mostly me being a newb. Nevertheless I figured since I was on here I would post this for anyone as lost as I was!