<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>How to grab shop methods</title>
    <link>http://forums.shopify.com/categories/9/posts/31397</link>
    <language>en-us</language>
    <description>Feed for discussion topic How to grab shop methods</description>
    <item>
      <title>How to grab shop methods</title>
      <author>Nath</author>
      <pubDate>Thu, 26 Nov 2009 22:11:10 +0000</pubDate>
      <link>http://forums.shopify.com/categories/9/posts/31397</link>
      <guid>http://forums.shopify.com/categories/9/posts/31397</guid>
      <description>&lt;p&gt;I've been playing around with the&amp;nbsp; Shopify API and have had some great success as im pretty new to RoR programming and using API's.&lt;/p&gt;
&lt;p&gt;I have been trying to get information from the shop object but am not sure on what the correct method is to do this. For example i currently have @shop = ShopifyAPI::Shop and am stuck from here on&lt;/p&gt;
&lt;p&gt;For getting product&amp;nbsp; information I can use find and parse in the params for the query I want to execute&lt;/p&gt;
&lt;p&gt;I appreciate any help / pointer you can give&lt;/p&gt;
&lt;p&gt;Nath&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Nath commented</title>
      <author>Nath</author>
      <pubDate>Thu, 26 Nov 2009 22:25:40 +0000</pubDate>
      <link>http://forums.shopify.com/categories/9/posts/31397#comment-31398</link>
      <guid>http://forums.shopify.com/categories/9/posts/31397#comment-31398</guid>
      <description>&lt;p&gt;Sorry,&lt;/p&gt;
&lt;p&gt;@shop = ShopifyAPI::Shop.current does the job&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Caroline Schnapp commented</title>
      <author>Caroline Schnapp</author>
      <pubDate>Fri, 27 Nov 2009 04:17:58 +0000</pubDate>
      <link>http://forums.shopify.com/categories/9/posts/31397#comment-31401</link>
      <guid>http://forums.shopify.com/categories/9/posts/31397#comment-31401</guid>
      <description>&lt;p&gt;Nath, I assume you used &lt;a href="http://github.com/Shopify/shopify_app"&gt;shopify_app&lt;/a&gt; to build you application?&lt;/p&gt;
&lt;p&gt;It seems like you can access current_shop.shop from any view or controller within the Shopify app, and that gives you the 'shop' resource. It is the same as ShopifyAPI::Shop.current.&lt;/p&gt;
&lt;p&gt;current_shop.shop is an Active Resource, and as such all these methods can be used on it: &lt;a href="http://api.rubyonrails.org/classes/ActiveResource/Base.html"&gt;http://api.rubyonrails.org/classes/ActiveResource/Base.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One of these methods is to_xml. So you can look at the XML response Shopify sent to your application:&lt;/p&gt;
&lt;pre&gt;&amp;lt;code&amp;gt;&amp;lt;%=h current_shop.shop.&lt;strong&gt;to_xml&lt;/strong&gt; %&amp;gt;&amp;lt;/code&amp;gt;&lt;/pre&gt;
&lt;p&gt;Of course, you can also look up the API documentation to see right away what kind of XML you &lt;em&gt;should&lt;/em&gt; have received: &lt;a href="http://api.shopify.com/shop.html"&gt;http://api.shopify.com/shop.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Looking at all this, you see that you can output the shop name like this, for example:&lt;/p&gt;
&lt;pre&gt;&amp;lt;p&amp;gt;Shop Name: &amp;lt;%= current_shop.shop.name %&amp;gt;&amp;lt;/p&amp;gt;&lt;/pre&gt;
&lt;p&gt;You can also get your resource as JSON to use in your JavaScript:&lt;/p&gt;
&lt;pre&gt;&amp;lt;script type="text/javascript" charset="utf-8"&amp;gt;&lt;br /&gt;//&amp;lt;![CDATA[&lt;br /&gt;  var shop = &amp;lt;%= current_shop.shop.to_json %&amp;gt;;&lt;br /&gt;  console.log(shop.name);&lt;br /&gt;//]]&amp;gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Nath commented</title>
      <author>Nath</author>
      <pubDate>Sat, 28 Nov 2009 09:26:22 +0000</pubDate>
      <link>http://forums.shopify.com/categories/9/posts/31397#comment-31433</link>
      <guid>http://forums.shopify.com/categories/9/posts/31397#comment-31433</guid>
      <description>&lt;p&gt;Thanks Caroline, Thats is really helpfull info.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
