Search by custom attribute in Intercom ruby gem - ruby

I am using Intercom ruby gem. One of my company responses looks like below:
#company_id="648",
#created_at=1578937499,
#custom_attributes=
{"cname"=>nil,
"contacts"=>1,
"ein"=>"xyz123"
}
In order to search by company_id, I can do this: intercom.companies.find(company_id: 648) (Reference: https://github.com/intercom/intercom-ruby#search-for-customers) . However, I want to search by one of the custom attributes ein. Is it possible to do that?

I don't think that is possible at the moment
From the latest API (version 2.3 right now) there is only ability to search contacts (users/leads) https://developers.intercom.com/intercom-api-reference/reference#search-for-contacts
Looks like retrieving companies can only be done via
name / company_id: https://developers.intercom.com/intercom-api-reference/reference#view-a-company
tag_id / segment_id: https://developers.intercom.com/intercom-api-reference/reference#list-companies

Related

Implement AEM search using query builder API using wildcard-contains in node name

I have a requirement to fetch search results based on partial/wild card in node name to retrieve AEM forms portal data.
For example, if there are multiple draft Id node under any user-email (Unique node created under /conten/forms/fp). each draft application node will reside under conten/forms/fp/.com|.net/metadata/draftId
Note: User nodes will have .com or .net in the end. Image also attached for reference. I should get testsonar#mailiantor.com/testsonar%40#mailinator.com as result since the user has more than one draft application.
My requirement is to find out users who are having multiple drafts. Can anyone suggest this would be possible using Query builder API . I have tried below predicate but noticed that wild card is not supporting in path.
type=nt:unstructured
path=/content/forms/fp/*/drafts/metadata
path.exact=false
path.false=false
When using predicates you should be able to use something like this:
group.1_property.value=%term%
group.1_property=jcr:path
group.1_property.operation=like

How to use my fulltext lucerne index in Neo4j.rb?

OK, so originally I followed this guide to create a fulltext index, and then I imported all my data onto my Neo4j server. The indexes work great, and now I'm trying to use Sinatra/Ruby to interact with my Neo4j graph.
I'm using the Neo4j ruby gem, and I've created a model (movie.rb) of Movies with a fulltext index on the title as per this wiki entry:
class Movie
include Neo4j::NodeMixin
property :id
property :movieID
property :name, :index => :fulltext
property :year
property :imdB
property :rtRating
property :poster
end
However, I am getting this error: NameError: uninitialized constant Neo4j::NodeMixin. The Neo4j Ruby wiki entry states that:
The neo4j-wrapper is included in the neo4j gem The neo4j-wrapper gem defines these mixins: Neo4j::NodeMixin
So it should be included in my project...
I have no idea how to continue... someone please help me search with my fulltext index?
I think we've already helped you with this separately, but for anybody running across this question:
For various reasons, the Neo4j.rb project doesn't have good support for the legacy indexes. That wiki page is out of date (I just updated it to say so). The searchkick gem is recommended for fulltext search functionality with Neo4j.rb.
Also note that there is a direct integration of elasticsearch with Neo4j:
https://github.com/neo4j-contrib/neo4j-elasticsearch
Here's a video tutorial:
https://www.youtube.com/watch?v=SJLSFsXgOvA
For that, though, I believe you would need to make your own HTTP requests to Neo4j to get the results from the plugin. The upside is that not all of your changes need to go through your Ruby app (like would be the case with searchkick)

How do I get a count of the Shopify products in a collection using the Ruby API

I want to get the count of products in each collection in the shop as part of a Shopify App that I'm building.
I know that for a single collection Product.all(params: {collection_id: 29238895}).count will show me the count in the shopify console, but I'm not certain about how it is implemented.
The API document describes a call that counts all products that belong to a certain collection GET /admin/products/count.json?collection_id=841564295 but I have been unable to get a ruby expression that runs this.
Is there a more complete document on the Ruby API?
If you want to know exactly what is going on with the API, may I suggest the simple command: bundle open shopify_api
That will load the entire API into your text editor, allowing to quickly determine the answer to your question. The /lib/resources directory is especially rich, but do not forget to check the base class as well. In fact, I think the count option is declared right in the base itself. Nothing beats a few minutes of examining the code.

Ruby DataMapper: How can I do pagination?

I am going to retrieve a list of objects.
get "/todoitems/?" do
debugger
todo = Todolist.all
todo.to_json
end
Is there example that can retrieve page by page?
Many thanks.
Here's a gem dm-pagination which provides pagination support for Datamapper
I also found dm-paginator
This should point you in the right direction:
http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#sec-pagination
Essentially, there's a gem called will-paginate that takes care of sorting things in a page by page structure. There's an example included in the link

How to get book cover from ISBN using Google Book API?

Is there a simple way to get book cover in JSON format from ISBN using Google Book API?
You can use the isbn: query, like this:
https://www.googleapis.com/books/v1/volumes?q=isbn:0771595158
This will return a proper JSON response containing either the book information or an error description if the ISBN is not found.
If you are looking for an answer for a Ruby (Rails, Sinatra or Console) answer on how to get a conver image or for that matter any detail available through the Google Books API, I think GoogleBooks gem is a good place to start.
For example, for the same scenario:
Install the gem
gem install googlebooks
Use the gem
require 'googlebooks'
GoogleBooks.search('isbn:9781443411080').first.image_link
first because it returns a collection of books.

Resources