Sha256: 94039b04de314a44e5249a6ef00b43bd26edb6ce0031a6a22fcfa9b456f4be3c
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
require "weeblycloud/cloudresource" require "weeblycloud/saveable" require "weeblycloud/site" require "weeblycloud/theme" module Weeblycloud # Represents a User resource. # https://cloud-developer.weebly.com/user.html class User < CloudResource include Saveable def initialize(user_id, data = nil) @user_id = user_id.to_i @endpoint = "user/#{@user_id}" super(data) end def id @user_id end def get response = @client.get(@endpoint) @properties = response.json["user"] end def enable result = @client.post(@endpoint + "/enable") return result.json["success"] end def disable result = @client.post(@endpoint + "/disable") return result.json["success"] end def login_link result = @client.post(@endpoint + "/loginLink") return result.json["link"] end def list_themes(filters={}) result = @client.get(@endpoint + "/theme", :params=>filters) return result.map {|i| Theme.new(@user_id, i["theme_id"], i)} end def list_sites(filters={}) result = @client.get(@endpoint + "/site", :params=>filters) return result.map {|i| Site.new(@user_id, i["site_id"], i)} end def create_theme(name, zip_url) data = {"theme_name" => name, "theme_zip" => zip_url} response = @client.post(@endpoint + "/theme", :content=>data) return Theme.new(@user_id, response.json["theme_id"]) end def create_site(domain, properties={}) properties.merge!({"domain"=>domain}) response = @client.post(@endpoint + "/site", :content=>properties) return Site.new(@user_id, response.json["site"]["site_id"]) end def get_site(site_id) return Site.new(@user_id, site_id) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
weeblycloud-1.0.0 | lib/weeblycloud/user.rb |