Merge branch 'master' of http://gitlab.tp.rulingcom.com/saurabh/orbit-4-2
This commit is contained in:
commit
655a1188f6
2
Gemfile
2
Gemfile
|
@ -20,7 +20,7 @@ gem "acts_as_unvlogable"
|
||||||
gem 'youtube_it'
|
gem 'youtube_it'
|
||||||
gem 'gotcha'
|
gem 'gotcha'
|
||||||
gem "geocoder"
|
gem "geocoder"
|
||||||
|
gem 'httparty'
|
||||||
#database
|
#database
|
||||||
gem 'mini_magick'
|
gem 'mini_magick'
|
||||||
gem 'mongoid', '> 2.1', '< 3.0.0'
|
gem 'mongoid', '> 2.1', '< 3.0.0'
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
class Admin::ModuleStoreController < OrbitBackendController
|
class Admin::ModuleStoreController < OrbitBackendController
|
||||||
|
before_filter :check_central_server_connection, :only => [:get_extensions]
|
||||||
@@store = STORE_CONFIG[:store_settings]["url"]
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@extensions = get_extensions
|
@extensions = get_extensions
|
||||||
|
@ -85,7 +84,7 @@ class Admin::ModuleStoreController < OrbitBackendController
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def get_extensions
|
def get_extensions
|
||||||
extensions = JSON.parse(open("#{@@store}/api/extensions").read)
|
extensions = store_session.extensions
|
||||||
|
|
||||||
exist_exts = []
|
exist_exts = []
|
||||||
ext_file = File.new("#{Rails.root}/downloaded_extensions.rb", "r")
|
ext_file = File.new("#{Rails.root}/downloaded_extensions.rb", "r")
|
||||||
|
@ -112,7 +111,7 @@ class Admin::ModuleStoreController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_extension(id)
|
def get_extension(id)
|
||||||
JSON.parse(open("#{@@store}/api/extensions/#{id}").read)
|
store_session.get_extension(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_downloaded_extension
|
def get_downloaded_extension
|
||||||
|
@ -142,4 +141,10 @@ class Admin::ModuleStoreController < OrbitBackendController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def get_site
|
||||||
|
@site ||= Site.first
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -0,0 +1,10 @@
|
||||||
|
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
|
def doorkeeper
|
||||||
|
oauth_data = request.env["omniauth.auth"]
|
||||||
|
@user = User.find_or_create_for_doorkeeper_oauth(oauth_data)
|
||||||
|
@user.update_doorkeeper_credentials(oauth_data)
|
||||||
|
@user.save
|
||||||
|
|
||||||
|
sign_in_and_redirect @user
|
||||||
|
end
|
||||||
|
end
|
|
@ -147,6 +147,11 @@ class Admin::SitesController < OrbitBackendController
|
||||||
render :text => "success"
|
render :text => "success"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def register_site
|
||||||
|
@site.register_site
|
||||||
|
redirect_to admin_module_store_path
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def update_design(design)
|
def update_design(design)
|
||||||
|
|
|
@ -3,24 +3,22 @@ require 'uri'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'zip/zip'
|
require 'zip/zip'
|
||||||
class Admin::TemplateStoreController < OrbitBackendController
|
class Admin::TemplateStoreController < OrbitBackendController
|
||||||
|
before_filter :check_central_server_connection, :only => [:get_templates]
|
||||||
|
before_filter :set_store
|
||||||
|
|
||||||
|
|
||||||
@@store_domain = STORE_CONFIG[:store_settings]["url"]
|
|
||||||
def index
|
def index
|
||||||
@store = @@store_domain
|
|
||||||
@design_ids = Design.all.map{|d| d.template_store_id}
|
@design_ids = Design.all.map{|d| d.template_store_id}
|
||||||
@templates = JSON.parse(get_templates)
|
@templates = get_templates.parsed_response
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@store = @@store_domain
|
|
||||||
@design_ids = Design.all.map{|d| d.template_store_id}
|
@design_ids = Design.all.map{|d| d.template_store_id}
|
||||||
@template = JSON.parse(get_template(params[:id])) rescue nil
|
@template = get_template(params[:id]).parsed_response rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_theme
|
def download_theme
|
||||||
url = @@store_domain + params["url"]
|
url = @store_url + params["url"]
|
||||||
url_base = url.split('/')[2]
|
url_base = url.split('/')[2]
|
||||||
url_path = '/'+url.split('/')[3..-1].join('/')
|
url_path = '/'+url.split('/')[3..-1].join('/')
|
||||||
Net::HTTP.start(url_base) do |http|
|
Net::HTTP.start(url_base) do |http|
|
||||||
|
@ -32,7 +30,7 @@ class Admin::TemplateStoreController < OrbitBackendController
|
||||||
end
|
end
|
||||||
upload_package("#{params['slug']}.zip", params["id"])
|
upload_package("#{params['slug']}.zip", params["id"])
|
||||||
File.delete("public/#{params['slug']}.zip")
|
File.delete("public/#{params['slug']}.zip")
|
||||||
render :json => {"success"=>true,"url"=>@@store_domain + params["url"]}.to_json
|
render :json => {"success"=>true,"url"=>@store_url + params["url"]}.to_json
|
||||||
end
|
end
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
@ -92,19 +90,15 @@ class Admin::TemplateStoreController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_template(id)
|
def get_template(id)
|
||||||
uri = URI.parse("#{@@store_domain}/api/templates/#{id}")
|
store_session.get_template(id)
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
|
||||||
request = Net::HTTP::Get.new(uri.request_uri)
|
|
||||||
response = http.request(request)
|
|
||||||
response.body
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_templates
|
def get_templates
|
||||||
uri = URI.parse("#{@@store_domain}/api/templates")
|
store_session.templates
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
end
|
||||||
request = Net::HTTP::Get.new(uri.request_uri)
|
|
||||||
response = http.request(request)
|
def set_store
|
||||||
response.body
|
@store_url = STORE_CONFIG[:store_settings]["url"]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -479,4 +479,18 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_central_server_connection
|
||||||
|
if @site.site_token?
|
||||||
|
flash[:notice]="Connected to the Store"
|
||||||
|
else
|
||||||
|
redirect_to admin_register_site_index_path
|
||||||
|
flash[:notice]="To Access the Store Please Connect It"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def store_session
|
||||||
|
api_key = STORE_CONFIG[:store_settings]["api_key"]
|
||||||
|
@store = Store.new(@site.id.to_s,@site.site_token,api_key) if @site.site_token
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class OrbitBackendController < ApplicationController
|
class OrbitBackendController < ApplicationController
|
||||||
include OrbitCategory::Categorizing
|
include OrbitCategory::Categorizing
|
||||||
include OrbitCoreLib::Authorization
|
include OrbitCoreLib::Authorization
|
||||||
|
include OrbitCoreLib::PermissionUtility
|
||||||
include OrbitTag::Tagging
|
include OrbitTag::Tagging
|
||||||
include AdminHelper
|
include AdminHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
|
@ -12,13 +12,13 @@ module OrbitBackendHelper
|
||||||
|
|
||||||
def show_form_status_field(object)
|
def show_form_status_field(object)
|
||||||
#by_object = (!object.is_expired? and object.is_pending?)
|
#by_object = (!object.is_expired? and object.is_pending?)
|
||||||
by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?)
|
by_user = ((object.category.user_is_authorized_by_title?(current_user,"category_approval_#{@module_app.key}") rescue nil) or is_manager? or is_admin?)
|
||||||
by_user
|
by_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_approval_link(object)
|
def show_approval_link(object)
|
||||||
by_object = (!object.is_expired? and object.is_pending?)
|
by_object = (!object.is_expired? and object.is_pending?)
|
||||||
by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?)
|
by_user = ((object.category.user_is_authorized_by_title?(current_user,"category_approval_#{@module_app.key}") rescue nil) or is_manager? or is_admin?)
|
||||||
by_object and by_user
|
by_object and by_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ module OrbitBackendHelper
|
||||||
content_tag :li, link_to(t(quick[:translation] || :authorization_), eval("#{quick[:link]}"), class: "preview_trigger #{quick[:class]}")
|
content_tag :li, link_to(t(quick[:translation] || :authorization_), eval("#{quick[:link]}"), class: "preview_trigger #{quick[:class]}")
|
||||||
end
|
end
|
||||||
when 'edit'
|
when 'edit'
|
||||||
if authorization && approvable
|
if authorization && approvable || is_manager?
|
||||||
content_tag :li, link_to(t(quick[:translation] || :edit), quick[:link].nil? ? '#' : eval("#{quick[:link]}('#{object.id}'#{link_option})"), class: quick[:class], data: eval("#{quick[:data]}"))
|
content_tag :li, link_to(t(quick[:translation] || :edit), quick[:link].nil? ? '#' : eval("#{quick[:link]}('#{object.id}'#{link_option})"), class: quick[:class], data: eval("#{quick[:data]}"))
|
||||||
end
|
end
|
||||||
when 'delete'
|
when 'delete'
|
||||||
|
|
|
@ -194,6 +194,7 @@ class ModuleApp
|
||||||
# authorization
|
# authorization
|
||||||
def update_auth_approval_users
|
def update_auth_approval_users
|
||||||
user_ids = self.auth_approvals.inject([]) do |users, auth|
|
user_ids = self.auth_approvals.inject([]) do |users, auth|
|
||||||
|
auth = auth.class.find(auth.id)
|
||||||
users += auth.authorized_users.map{|user| user.id}
|
users += auth.authorized_users.map{|user| user.id}
|
||||||
end
|
end
|
||||||
self.update_attribute(:auth_approval_users, user_ids.uniq)
|
self.update_attribute(:auth_approval_users, user_ids.uniq)
|
||||||
|
|
|
@ -46,14 +46,15 @@ class Site
|
||||||
field :address
|
field :address
|
||||||
field :phone_number, :type => Array,:default=>[]
|
field :phone_number, :type => Array,:default=>[]
|
||||||
field :mobile_bar_color, :type => Array, :default=>[]
|
field :mobile_bar_color, :type => Array, :default=>[]
|
||||||
|
field :site_token
|
||||||
|
|
||||||
field :mobile_on, :type => Boolean, :default => false
|
field :mobile_on, :type => Boolean, :default => false
|
||||||
|
|
||||||
belongs_to :design
|
belongs_to :design
|
||||||
has_many :site_metas, :autosave => true, :dependent => :destroy
|
has_many :site_metas, :autosave => true, :dependent => :destroy
|
||||||
validate :in_use_locales, :minimum_enabled_locales
|
validate :in_use_locales, :minimum_enabled_locales
|
||||||
|
|
||||||
|
index({ access_token: 1}, { unique: true })
|
||||||
|
|
||||||
def minimum_enabled_locales
|
def minimum_enabled_locales
|
||||||
size = self.in_use_locales.length
|
size = self.in_use_locales.length
|
||||||
if size < 1
|
if size < 1
|
||||||
|
@ -96,4 +97,18 @@ class Site
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_site_token
|
||||||
|
if self.site_token.nil?
|
||||||
|
self.site_token = SecureRandom.uuid.gsub('-','')
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def register_site
|
||||||
|
api_key = STORE_CONFIG[:store_settings]["api_key"]
|
||||||
|
self.generate_site_token
|
||||||
|
store = Store.new(self.id.to_s,self.site_token,api_key)
|
||||||
|
store.post_client(self.id.to_s,self.site_token,self.name)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -184,7 +184,6 @@
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel-heading"><i class="icon-shopping-cart"></i><span class="break"></span><%= t(:module_store) %></div>
|
<div class="panel-heading"><i class="icon-shopping-cart"></i><span class="break"></span><%= t(:module_store) %></div>
|
||||||
<div class="pannel-body">
|
<div class="pannel-body">
|
||||||
|
|
||||||
<table id="mt-list" class="table main-list">
|
<table id="mt-list" class="table main-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="sort-header">
|
<tr class="sort-header">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="<%= admin_template_store_template_path(template["_slugs"][0]) %>">
|
<a href="<%= admin_template_store_template_path(template["_slugs"][0]) %>">
|
||||||
<img src="<%= @store + template['preview']['preview']['thumb']['url'] %>" class="item-thumb" />
|
<img src="<%= @store_url + template['preview']['preview']['thumb']['url'] %>" class="item-thumb" />
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
<th class="span1">Status</th>
|
<th class="span1">Status</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<%= render :partial => 'template', :collection => @templates %>
|
<%= render :partial => 'template', :collection => @templates %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div id="content" class="clearfix">
|
<div id="content" class="clearfix">
|
||||||
<div class="side">
|
<div class="side">
|
||||||
<div id="item-info">
|
<div id="item-info">
|
||||||
<%= image_tag "#{@store}#{@template['preview']['preview']['thumb']['url']}", :class => "item-thumb" %>
|
<%= image_tag "#{@store_url}/#{@template['preview']['preview']['thumb']['url']}", :class => "item-thumb" %>
|
||||||
<h2 class="item-name"><%= @template['title'] %></h2>
|
<h2 class="item-name"><%= @template['title'] %></h2>
|
||||||
<% if @design_ids.include?(@template["_id"]["$oid"]) %>
|
<% if @design_ids.include?(@template["_id"]["$oid"]) %>
|
||||||
<%= link_to "Installed", "javascript:void(0);", "data-url" => @template['template']['template']['url'], :class=> 'btn btn-success download-link', "disabled"=>"disabled", "data-name"=>@template['title'], "data-slug"=>@template["_slugs"][0], "data-id"=>@template["_id"]["$oid"] %>
|
<%= link_to "Installed", "javascript:void(0);", "data-url" => @template['template']['template']['url'], :class=> 'btn btn-success download-link', "disabled"=>"disabled", "data-name"=>@template['title'], "data-slug"=>@template["_slugs"][0], "data-id"=>@template["_id"]["$oid"] %>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
if defined?(PhusionPassenger)
|
||||||
|
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
||||||
|
if forked
|
||||||
|
Resque.redis.client.disconnect
|
||||||
|
Resque.redis = Redis.new(:host => 'localhost', :port => 6379)
|
||||||
|
Resque.redis.namespace = Site.first.resque_namespace rescue APP_CONFIG['orbit']
|
||||||
|
else
|
||||||
|
# We're in conservative spawning mode. We don't need to do anything.
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -229,11 +229,13 @@ en:
|
||||||
groups: Groups
|
groups: Groups
|
||||||
help: Help
|
help: Help
|
||||||
hidden: Hidden
|
hidden: Hidden
|
||||||
|
is_hidden: Hidden
|
||||||
hide: Hide
|
hide: Hide
|
||||||
hits: Hits
|
hits: Hits
|
||||||
homepage: Homepage
|
homepage: Homepage
|
||||||
horizontal: Horizontal
|
horizontal: Horizontal
|
||||||
hot: Hot
|
hot: Hot
|
||||||
|
is_hot: Hot
|
||||||
image: Image
|
image: Image
|
||||||
images: Images
|
images: Images
|
||||||
info: Information
|
info: Information
|
||||||
|
@ -352,11 +354,13 @@ en:
|
||||||
public_r_tag: System Widget
|
public_r_tag: System Widget
|
||||||
text: Text Area
|
text: Text Area
|
||||||
passed: Approved
|
passed: Approved
|
||||||
|
is_checked: Approved
|
||||||
password: Password
|
password: Password
|
||||||
password_change: Change password
|
password_change: Change password
|
||||||
password_confirmation: Password confirmation
|
password_confirmation: Password confirmation
|
||||||
password_current: Current password
|
password_current: Current password
|
||||||
pending: Pending
|
pending: Pending
|
||||||
|
is_pending: Pending
|
||||||
personal_plugins:
|
personal_plugins:
|
||||||
author : "Author"
|
author : "Author"
|
||||||
edit_brief_intro : "Edit Brief Intro."
|
edit_brief_intro : "Edit Brief Intro."
|
||||||
|
@ -400,6 +404,7 @@ en:
|
||||||
register: Register
|
register: Register
|
||||||
registered: Registered
|
registered: Registered
|
||||||
rejected: Rejected
|
rejected: Rejected
|
||||||
|
is_rejected: Rejected
|
||||||
rejected_reason: 'Reason:'
|
rejected_reason: 'Reason:'
|
||||||
rejected_reason_empty: "Approval rejected, no referencable information"
|
rejected_reason_empty: "Approval rejected, no referencable information"
|
||||||
related_links: Related Links
|
related_links: Related Links
|
||||||
|
@ -527,6 +532,7 @@ en:
|
||||||
to_search: Set as Search Key
|
to_search: Set as Search Key
|
||||||
to_show: Display in frontend
|
to_show: Display in frontend
|
||||||
top: Top
|
top: Top
|
||||||
|
is_top: Top
|
||||||
total_visitors: Total Visitors
|
total_visitors: Total Visitors
|
||||||
traffic: Traffic
|
traffic: Traffic
|
||||||
type: Field Type
|
type: Field Type
|
||||||
|
|
|
@ -355,11 +355,13 @@ zh_tw:
|
||||||
public_r_tag: 系統模塊
|
public_r_tag: 系統模塊
|
||||||
text: 文字區域
|
text: 文字區域
|
||||||
passed: 通過審核
|
passed: 通過審核
|
||||||
|
is_checked: 通過審核
|
||||||
password: 密碼
|
password: 密碼
|
||||||
password_change: 更改密碼
|
password_change: 更改密碼
|
||||||
password_confirmation: 確認密碼
|
password_confirmation: 確認密碼
|
||||||
password_current: 目前的密碼
|
password_current: 目前的密碼
|
||||||
pending: 待審核
|
pending: 待審核
|
||||||
|
is_pending: 待審核
|
||||||
personal_plugins:
|
personal_plugins:
|
||||||
author : "著作人"
|
author : "著作人"
|
||||||
edit_brief_intro : "編輯摘要"
|
edit_brief_intro : "編輯摘要"
|
||||||
|
@ -402,6 +404,7 @@ zh_tw:
|
||||||
register: 註冊
|
register: 註冊
|
||||||
registered: 已註冊
|
registered: 已註冊
|
||||||
rejected: 拒絕
|
rejected: 拒絕
|
||||||
|
is_rejected: 拒絕
|
||||||
rejected_reason: 拒絕原因:'
|
rejected_reason: 拒絕原因:'
|
||||||
rejected_reason_empty: "拒絕核准, 沒有參考資訊"
|
rejected_reason_empty: "拒絕核准, 沒有參考資訊"
|
||||||
related_links: 相關連結
|
related_links: 相關連結
|
||||||
|
|
|
@ -220,6 +220,7 @@ Orbit::Application.routes.draw do
|
||||||
get 'update_orbit'
|
get 'update_orbit'
|
||||||
get 'restart_server'
|
get 'restart_server'
|
||||||
end
|
end
|
||||||
|
match 'sites/register_site' => "sites#register_site"
|
||||||
|
|
||||||
resources :tags do
|
resources :tags do
|
||||||
collection do
|
collection do
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
store_settings:
|
store_settings:
|
||||||
url: "http://store.tp.rulingcom.com"
|
url: "http://store.tp.rulingcom.com"
|
||||||
|
api_url: "http://store.tp.rulingcom.com/api"
|
||||||
|
api_key: 'Token token="2870f77e59168dbe3fbdffba466c7c8d"'
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
module OmniAuth
|
||||||
|
module Strategies
|
||||||
|
class Doorkeeper < OmniAuth::Strategies::OAuth2
|
||||||
|
option :name, :doorkeeper
|
||||||
|
|
||||||
|
option :client_options, {
|
||||||
|
:site => "http://localhost:8000",
|
||||||
|
:authorize_path => "/oauth/authorize"
|
||||||
|
}
|
||||||
|
|
||||||
|
uid do
|
||||||
|
raw_info["id"]
|
||||||
|
end
|
||||||
|
|
||||||
|
info do
|
||||||
|
{
|
||||||
|
:email => raw_info["email"]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def raw_info
|
||||||
|
@raw_info ||= access_token.get('/api/v1/me.json').parsed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -234,7 +234,7 @@ module OrbitCoreLib
|
||||||
when :sub_manager
|
when :sub_manager
|
||||||
@open ||= check_sub_manager
|
@open ||= check_sub_manager
|
||||||
when :approver
|
when :approver
|
||||||
@open ||= check_sub_manager
|
@open ||= check_approver
|
||||||
when :user
|
when :user
|
||||||
@open ||= true
|
@open ||= true
|
||||||
when :visitor
|
when :visitor
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
require 'httparty'
|
||||||
|
class Store
|
||||||
|
include HTTParty
|
||||||
|
|
||||||
|
format :json
|
||||||
|
base_uri STORE_CONFIG[:store_settings]["api_url"]
|
||||||
|
|
||||||
|
def initialize(site_id,site_token,api_key)
|
||||||
|
@options_for_get = {
|
||||||
|
headers: {
|
||||||
|
"Authorization" => api_key,
|
||||||
|
"X-SiteToken" => site_token,
|
||||||
|
"X-SiteId" => site_id,
|
||||||
|
"Content-Type" => "application/json",
|
||||||
|
'Accept' => 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@options_for_client = {
|
||||||
|
headers: {
|
||||||
|
"Authorization" => api_key,
|
||||||
|
"Content-Type" => "application/json",
|
||||||
|
'Accept' => 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def templates(options={})
|
||||||
|
options = @options_for_get
|
||||||
|
self.class.get('/templates', options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_template(id)
|
||||||
|
options = @options_for_get
|
||||||
|
self.class.get("/templates/#{id}", options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def extensions(options={})
|
||||||
|
options = @options_for_get
|
||||||
|
self.class.get('/extensions', options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_extension(id)
|
||||||
|
options = @options_for_get
|
||||||
|
self.class.get("/extensions/#{id}", options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def post_client(site_id,site_token,site_name)
|
||||||
|
options = @options_for_client.merge({ :body => {:site_name => site_name, :site_id => site_id, :site_token => site_token}.to_json })
|
||||||
|
self.class.post('/clients', options )
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue