Sha256: f9c5701a5fe793651f478a4516a4b8b293402647382c54b4133c2846c08a6bc6

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

module Nusii
  module ApiOperations
    class NestedCreate < Create

      attr_reader :resource_class, :nested_resource_id,
                  :nested_resource_class, :params

      def initialize resource_class, nested_resource_id, nested_resource_class, params
        @resource_class        = resource_class
        @nested_resource_id    = nested_resource_id
        @nested_resource_class = nested_resource_class
        @params                = params
      end

    private

      def response
        @response ||= connection.post resource_path, params.to_json
      end

      def resource_path
        "/api/v2/#{nested_resource_url_string}/#{nested_resource_id}/#{resource_url_string}"
      end

      def nested_resource_url_string
        nested_resource_class.class_name.downcase.pluralize
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nusii-0.1.1 lib/nusii/api_operations/nested_create.rb