Sha256: dbfd03d6a9e23f75d2ce025f3d1a3c42741250b04958c8478a99b53263b13638

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 Bytes

Contents

module Helium
  class Client
    module Elements
      def elements
        response = get('/element')
        elements_data = JSON.parse(response.body)["data"]

        elements = elements_data.map do |element_data|
          Element.new(client: self, params: element_data)
        end

        return elements
      end

      def element(id)
        response = get("/element/#{id}")
        element_data = JSON.parse(response.body)["data"]

        return Element.new(client: self, params: element_data)
      end

      def update_element(element, name:)
        path = "/element/#{element.id}"

        body = {
          data: {
            attributes: {
              name: name
            },
            id: element.id,
            type: "element"
          }
        }

        response = patch(path, body: body)
        element_data = JSON.parse(response.body)["data"]

        return Element.new(client: self, params: element_data)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
helium-ruby-0.4.0 lib/helium/client/elements.rb