lib/ravelry/pattern.rb in ravelry-0.0.5 vs lib/ravelry/pattern.rb in ravelry-0.0.6

- old
+ new

@@ -1,10 +1,10 @@ module Ravelry # `Ravelry::Pattern` corresponds to Pattern objects in Ravelry. # - # This class requires your environment variables be set (see {file:README.md README}). API calls are authenticated using HTTP Basic Auth unless otherwise noted. + # This class requires your configuration variables be set (see {file:README.md README}). API calls are authenticated using HTTP Basic Auth unless otherwise noted. # # If your `pattern.data` is missing one of the attributes below, that method will return `nil`. # # #Pattern objects # @@ -62,21 +62,21 @@ # You will need to call special methods to create the associated objects with your pattern. # # To create all associated objects at once, call the following method after initialization: # # ```ruby - # pattern.build_all_objects + # pattern.build # ``` # # Note that this does not perform an API call: it creates the objects using the data returned from the initial `get` for your pattern object. # # This will create the following objects and readers from the existing `data`: # # * `pattern.author` - a {Ravelry::Author} object # * `pattern.categories` - an array of {Ravelry::Category} objects # * `pattern.craft` - a {Ravelry::Craft} object - # * `pattern.needles` - an array of {Ravelry::PatternNeedle} objects + # * `pattern.needles` - an array of {Ravelry::Needle} objects # * `pattern.packs` - array of {Ravelry::Pack} objects # * `pattern.photos` - an array of {Ravelry::Photo} objects # * `pattern.printings` - an array of {Raverly::Printing} objects # * `pattern.type` - a {Ravelry::PatternType} object # * `pattern.yarns` - array of {Ravelry::Yarn} objects @@ -89,14 +89,14 @@ include Build attr_reader :author, :categories, :craft, :needles, :packs, :photos, :printings, :type, :yarns, :yarn_weights # Handles GET API call and parses JSON response. + # + # Corresponds to Ravelry API endpoint `Patterns#show` # def get - request = Typhoeus::Request.get("https://api.ravelry.com/patterns/#{@id}.json", userpwd: "#{Ravelry.configuration.access_key}:#{Ravelry.configuration.personal_key}") - result = JSON.parse(request.response_body, {symbolize_names: true}) - @data = result[:pattern] + @data = Utils::Request.get("patterns/#{@id}.json", :pattern) end # Creates all objects associated with your pattern; returns nothing; sets `attr_readers`. # def build \ No newline at end of file