gcx_api 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4d44b161e7902d0f9908145cf59f230522df62d
4
- data.tar.gz: f157cf1f64e5c5bf28b5f5b51c7502f7e75b3447
3
+ metadata.gz: 5ac495d5f66e0508f4cbf61f0cddf341be541587
4
+ data.tar.gz: 03e6bff87878cae3079a77aff78a1984652713ea
5
5
  SHA512:
6
- metadata.gz: 1ca701c8aa4bca36a2434d65d28bcb220e2fbd4a8238194d09da445a8e79ec56ebf491832210980acc6bbde3da0e4e8bdccc7489fb779670a6f5d4f6534a7db7
7
- data.tar.gz: dc1d60afd35b77cfa5a06e0fc7b4da3b4cdff0955037d97ff8ca55fb4af0bc6d75363e678915e15fe7c47dd0fd32bd6773bfe9689f65dec9d0b2371351360251
6
+ metadata.gz: 62c26abdb0700d49d29c9ac9d16c8aaa687e86a04de733c3c6652d91cd13e3b76318cc7384e3915eba982d7be442c9e00b4e3e0a34ba050f06e49513cc05ce66
7
+ data.tar.gz: af3935fbe518fb99019696c27f31b447e95f79aa1ecf63618eb9e4d8089cfaa550635e4b6934d2a844c4317c1bacd0b5146ef64821eddd4584f3b38500e3a565
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  vendor/ruby
19
+ .idea
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in gcx_api.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake'
data/lib/gcx_api/site.rb CHANGED
@@ -8,7 +8,7 @@ class GcxApi::Site
8
8
  DEFAULTS = {privacy: 'public',
9
9
  theme: 'amped'}
10
10
 
11
- attr_accessor :name, :title, :privacy, :theme, :sitetype, :attributes
11
+ attr_accessor :name, :title, :privacy, :theme, :sitetype, :domain, :attributes
12
12
 
13
13
  validates :name, presence: true, gcx_site_name: true, format: /\A[a-z][a-z0-9_\-]{2,79}\z/i
14
14
  validates :title, presence: true
@@ -32,15 +32,15 @@ class GcxApi::Site
32
32
  ticket = GcxApi::Cas.new.get_cas_service_ticket(create_endpoint)
33
33
 
34
34
  res = RestClient::Request.execute(:method => :post, :url => create_endpoint + '?ticket=' + ticket, :payload => parameters, :timeout => -1) { |response, request, result, &block|
35
- Rails.logger.debug request
36
- Rails.logger.debug result.inspect
37
- # check for error response
38
- if [301, 302, 307].include? response.code
39
- response.follow_redirection(request, result, &block)
40
- elsif response.code.to_i != 200
41
- raise response.headers.inspect + response.inspect
42
- end
43
- response.to_str
35
+ Rails.logger.debug request
36
+ Rails.logger.debug result.inspect
37
+ # check for error response
38
+ if [301, 302, 307].include? response.code
39
+ response.follow_redirection(request, result, &block)
40
+ elsif response.code.to_i != 200
41
+ raise response.headers.inspect + response.inspect
42
+ end
43
+ response.to_str
44
44
  }
45
45
  community = JSON.parse(res)
46
46
  if community['errors']
@@ -51,6 +51,37 @@ class GcxApi::Site
51
51
  end
52
52
  end
53
53
 
54
+ def set_option_values(options)
55
+ options_endpoint = (domain || GcxApi.gcx_url) + '/' + name + '/index.php'
56
+
57
+ RestClient::Request.execute(:method => :post, :url => options_endpoint, :payload => options, :timeout => -1) { |response, request, result, &block|
58
+ Rails.logger.debug request
59
+ Rails.logger.debug result.inspect
60
+ # check for error response
61
+ if response.code.to_i != 200
62
+ raise response.headers.inspect + response.inspect
63
+ end
64
+ response.to_str
65
+ }
66
+ end
67
+
68
+
69
+ def destroy(site_name)
70
+ destroy_endpoint = GcxApi.gcx_url + "/#{site_name}/wp-gcx/delete-community.php"
71
+
72
+ ticket = GcxApi::Cas.new.get_cas_service_ticket(destroy_endpoint)
73
+
74
+ res = RestClient::Request.execute(:method => :post, :url => destroy_endpoint + '?ticket=' + ticket, :payload => {}, :timeout => -1) { |response, request, result, &block|
75
+ Rails.logger.debug request
76
+ Rails.logger.debug result.inspect
77
+ # check for error response
78
+ if response.code.to_i != 200
79
+ raise result.inspect
80
+ end
81
+ response.to_str
82
+ }
83
+ end
84
+
54
85
  def persisted?
55
86
  @persisted
56
87
  end
@@ -1,3 +1,3 @@
1
1
  module GcxApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcx_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Starcher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-30 00:00:00.000000000 Z
11
+ date: 2017-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ox
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Ruby library for the GCX API
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - Gemfile
50
50
  - LICENSE.txt
51
51
  - README.md
@@ -66,17 +66,17 @@ require_paths:
66
66
  - lib
67
67
  required_ruby_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.0.6
79
+ rubygems_version: 2.5.1
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Ruby library for the GCX API