module <%= module_name %>
  class <%= simple_class_name %> < <%= module_name %>::Base
    # Point to your service endpoint & path
    # self.service_endpoint = "http://your-service-endpoint.twitch.tv"

    # Set your primary key attribute
    # self.primary_attribute = :id

    <%- if attributes.any? -%>
    attributes <%= attributes.map { |a| ":#{a.name}" }.join(", ") %>

    validates <%= attributes.map { |a| ":#{a.name}" }.join(", ") %>, presence: true
    <%- else -%>
    # Specify attributes if any
    # attributes :attribute1, :attribute2, :attribute3

    # validates :attribute1, presence: true
    # validates :attribute2, uniqueness: true
    # validates :attribute3, numericality: true
    <%- end -%>

    def self.all(options = {})
      raise "<%= module_name %>::<%= simple_class_name %>#all needs to be implemented"

      # response = get "/<%= pluralized_name %>", params: options

      # <%= pluralized_name %> = response.body["<%= pluralized_name %>"].map do |<%= singularized_name %>_attributes|
      #   from_attributes(<%= singularized_name %>_attributes)
      # end

      # paginate <%= pluralized_name %>, total_pages: response.body["total_pages"]
      # paginate <%= pluralized_name %>, count: response.body["count"], per_page: options["per_page"]
      # paginate <%= pluralized_name %>
    end

    def self.find(id, options = {})
      raise "<%= module_name %>::<%= simple_class_name %>#find needs to be implemented"

      # response = get "/<%= pluralized_name %>/#{id}", params: options

      # if response.success?
      #   from_attributes(response.body["<%= singularized_name %>"])
      # else
      #   from_errors(response.body["errors"])
      # end
    end

    def save
      raise "<%= module_name %>::<%= simple_class_name %>#save needs to be implemented"

      # return false unless valid?

      # response = if persisted?
      #   put "/<%= pluralized_name %>/#{primary_attribute_value}", body: as_json
      # else
      #   post "/<%= pluralized_name %>", body: as_json
      # end

      # self.errors = response.body["errors"] unless response.success?

      # response.success?
    end

    def destroy
      raise "<%= module_name %>::<%= simple_class_name %>#destroy needs to be implemented"

      # response = delete "/<%= pluralized_name %>/#{primary_attribute_value}"

      # self.errors = response.body["errors"] unless response.success?

      # response.success?
    end
  end
end
