Sha256: 3707c4b201a7389f6ba53feca47eea825e8adbc48c1bf6e8b5f46522b95055e4

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

require "weeblycloud/cloudresource"

require "weeblycloud/formentry"

module Weeblycloud

  # Represents a Form resource.
  # https://cloud-developer.weebly.com/form.html
  class Form < CloudResource

    def initialize(user_id, site_id, form_id, data = nil)
      @user_id = user_id.to_i
      @site_id = site_id.to_i
      @form_id = form_id.to_i

      @endpoint = "user/#{@user_id}/site/#{@site_id}/form/#{@form_id}"

      super(data)
    end

    # Returns the form_id
    def id
      @form_id
    end

    # Returns a list of FormEntry resources for a given form subject to filters.
    def list_form_entries(filters={})
      result = @client.get(@endpoint + "/entry", :params=>filters)
      return result.map { |i| FormEntry.new(@user_id, @site_id, i["form_entry_id"], i) }
    end

    # Return the FormEntry with the given id.
    def get_form_entry(form_entry_id)
      return FormEntry.new(@user_id, @site_id, @form_id, @form_entry_id)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weeblycloud-1.0.0 lib/weeblycloud/form.rb