Use shopify Price Rules api to create discounts in RoR - ruby-on-rails

I am developing an app for shopify app store in RoR and trying to use Shopify's new PriceRules API. But I am not able to make it work. I am using shopify-app gem and for price rules api I tries using:
ShopifyAPI::PriceRule
ShopifyAPI::PriceRules
but it throws following error :
uninitialized constant ShopifyAPI::PriceRule
Does anyone has any idea on how can I make it work in Ror?
Thanks.

Do a bundle open shopify_api and examine the resources. You probably won't find the new-ish PriceRules endpoint. So you have to make it yourself or wait if you want the official Shopify one.
If you are using RoR, then you almost certainly are using bundler. An alternative is to open the Shopify Gem shopify_api, and you'll see all the resources currently supported. If you wanted to add PriceRules endpoint, hack it into that gem.

Related

Is it possible to add Shopify app to already existing Ruby on Rails web app?

I want to integrate my web app with Shopify which means I have to create my own Shopify app. I noticed that Shopify requires self hosting so it would benefit me to add the Shopify app as part of my already existing web app because I can host it together.
Does this seem possible or do I have to make a desperate application?
It should totally be possible to add a shopify app to your existing ruby on rails project.
If you look at https://github.com/Shopify/shopify_app all you have to do is add in shopify_app to your gem file and then generate the proper routes. You can use their built-in generators or manually make the routes yourself.
Basically you would just need to make additional routes for your existing application to handle the requests to and from Shopify.

Rails: Shopify integration withouth a shopify app?

I'm going to use the https://github.com/Shopify/shopify_app Gem
I want to be able to pull the orders into my rails app using the Shopify API.
The question I have is it possible to connect to a Shopify store without creating a Shopify app, like the eBay model?
Thanks
I'm pretty sure the answer is no. To do anything with the API you need to send the store's OAuth token, and you can't get that unless the store installs your app.
Since the following works, I don't see why not?
curl https://${api_user}:${api_key}#${your_store}.com/admin/orders.json?ids=${order_id}
Source: https://help.shopify.com/api/reference/order#index
Just use your favourite http lib/gem.
Shopify is a hosted solution.
It only allows communication from other apps through an API, and only if your app is run/initiated from their environment with authention tokens (even though your app's real code will be hosted on your server)
You can use the Shopify private app which will provide you the secret and passwords and you can assign the needful resources you want to use and you can easily pull data from shopify without any public app
https://help.shopify.com/en/manual/apps/private-apps#generate-credentials-from-the-shopify-admin
Hope it will help
It's possible with GraphQL. Here's a codepen I use often (in javascript, not ruby, sorry) to quickly test if it's working.
Just replace the contents of the endpoint and query variables with your store and query.

octopress (ruby on rails) stripe integration

I would like to integrate stripe payment system to my octopress blog. The problem is that octopress is used to build static web sites, and integration stripe requires to add new Controllers (dynamic) to handle user payments.
how can I add such a controller without breaking the octopress file structure.
regards,
I'm not familiar with octopress. But I'm assuming it's similar to Wordpress, and whenever I want to use rails functionality on a wordpress application, I create a subdomain that points to my rails app using a service like dnsimple.
So if someone visits railsapp.mywebsiteurl.com they will receive a response from my rails application. However, if someone visits www.mywebsiteurl.com they will get a response from octopress.

Facebook gem for Ruby on Rails

I am going to make a very simple web application. I only need the friend list of the current user and then send a message to a selected user with an image/text. I have looked after gems that wraps the detail of extracting data from Facebook and I found some gems, but they all use the old REST API. First of all: is it bad to use the REST API? If not, is "Facebooker" a good gem? If it is bad I found this Which Ruby gems support the Facebook API? but I don't see much of documentation for the Facebooker2. Are there other options?
i'm using koala - works with OAuth authentication and Facebook Graph API. Didn't have any serious problems with it, and it's pretty well documented (with examples) on github
The Ruby Toolbox is a great resource for this kind of question.
In your case, try searching for 'facebook' -- as in https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=facebook -- and you'll find that https://github.com/nov/fb_graph is a popular and well-maintained FB gem (at least riight now).
Since Facebook introduced the Open Graph API I've found it's pretty easy to just roll my own wrapper for the REST calls I need using an http client like HTTParty or RestClient. YMMV.

Putting Rails app on GAE

I am using Rails 2.3.4 on windows. What are the steps to put my rails application on google app engine and allow only authorized users to view it?
Does it have to be GAE? If you just want a cloud solution you could maybe look at heroku (http://heroku.com/).
If it has to be GAE you'll need to make sure your app runs on jruby. You're also not going to be able to use active record.
Here's a good guide on how you can get a rails app on GAE:
http://olabini.com/blog/2009/04/jruby-on-rails-on-google-app-engine/
It does not have to be GAE. I just need to be able to put my rails app on a website where a limited set of users can view it. I have never deployed a rails app before so I am not sure which is the best way to get this done.

Resources