onsip 0.1.2 → 0.1.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: 94b6eb63cb2560ca7b8e241acccd9dbc8ff0672b
4
- data.tar.gz: 76560e45e7097d8f5914fff04a98d8f5d1a4d732
3
+ metadata.gz: c3ed072c8d8de68494fa64b7f526fb07c2635c02
4
+ data.tar.gz: e6129831f8a69f7d8b905309c763de07b008e7ab
5
5
  SHA512:
6
- metadata.gz: 6ab6f2048453c3ba6e51132390a2820ccc291d1fc28ec1def745b50a227b60c2f809e3c86d7e97347d5ca5ba461fca3108e7dfcaebf4f2cd9574af920c31359c
7
- data.tar.gz: d48c79f561b781782655131619f3f6aaab7eae1e56b7f2bfc69cd3ee9de06d0087bcce5a9effd8a10a9c8f80b8d7b64b1b51ca290cc5a237ca91647080df87b7
6
+ metadata.gz: b963f68abc2cc5f2f2e1efe5e73c6f43f79e5b52fd1c504dd74db21d0fe9ed0a6dc57a30e00d883e099c7681f9cad3606a0238d446d7ad63c8e1080ffa56c8af
7
+ data.tar.gz: 8892a945c0bd2caae98f1be9e20fadb051e1fcc104818a1a663a93797886fd6d322261b61ad11009f3fe1ff826b64f66652beb8f3c32b79b954c563ca62fda9d
@@ -25,6 +25,10 @@ module OnSIP
25
25
  User.add self, attrs
26
26
  end
27
27
 
28
+ def migrate_domain(new_domain)
29
+ self.class.migrate_domain(self.id, self.attributes.Domain, new_domain)
30
+ end
31
+
28
32
  module ClassMethods
29
33
  def browse(account_id)
30
34
  params = {'Action' => 'OrganizationBrowse', 'AccountId' => account_id, 'SessionId' => OnSIP.session.id, 'Output' => 'json'}
@@ -61,18 +65,31 @@ module OnSIP
61
65
  organization
62
66
  end
63
67
 
64
- # TODO
65
- def add(*args)
66
- raise NotImplementedError
68
+ def migrate_domain(organization_id, old_domain, new_domain)
69
+ params = {'Action' => 'OrganizationMigrateDomain', 'OrganizationId' => organization_id, 'OldDomain' => old_domain, 'NewDomain' => new_domain, 'SessionId' => OnSIP.session.id, 'Output' => 'json'}
70
+ response = OnSIP.connection.get('/api', params, {})
71
+ yield response if block_given?
72
+ process_migrate_domain_response response
73
+ end
74
+
75
+ def process_migrate_domain_response(response)
76
+ organization = nil
77
+
78
+ key_path = %w(Response Result OrganizationMigrateDomain Organization)
79
+ a = ResponseParser.parse_response response, key_path
80
+ yield response if block_given?
81
+ organization = (a.map { |h| new h }).first if a
82
+
83
+ organization
67
84
  end
68
85
 
69
86
  # TODO
70
- def edit_contact(*args)
87
+ def add(*args)
71
88
  raise NotImplementedError
72
89
  end
73
90
 
74
91
  # TODO
75
- def migrate_domain(*args)
92
+ def edit_contact(*args)
76
93
  raise NotImplementedError
77
94
  end
78
95
 
@@ -54,6 +54,10 @@ module OnSIP
54
54
  UserAddress.browse({'UserId' => self.id})
55
55
  end
56
56
 
57
+ def change_role(role)
58
+ self.class.change_role self.id, role
59
+ end
60
+
57
61
  module ClassMethods
58
62
  include Model::ClassMethods
59
63
 
@@ -173,6 +177,27 @@ module OnSIP
173
177
 
174
178
  user
175
179
  end
180
+
181
+ def change_role(user_id, role)
182
+ response = OnSIP.connection.get('/api', {'Action' => 'UserEditRoleSubmit', 'UserId' => user_id, 'SessionId' => OnSIP.session.id, 'RoleNames[]' => role, 'Output' => 'json'}, {})
183
+ yield response if block_given?
184
+ process_change_role_user_response response
185
+ end
186
+
187
+ def process_change_role_user_response(response)
188
+ user = nil
189
+
190
+ key_path = %w(Response Result UserEditRoleSubmit User)
191
+ a = ResponseParser.parse_response response, key_path
192
+ user = (a.map { |h| new h }).first if a
193
+
194
+ user
195
+ end
196
+
197
+ def generate_random_password(length = 8)
198
+ SecureRandom.urlsafe_base64[0,8]
199
+ end
200
+
176
201
  end
177
202
 
178
203
  extend ClassMethods
data/lib/onsip/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OnSIP
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onsip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Larrimore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-17 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -336,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
336
  version: '0'
337
337
  requirements: []
338
338
  rubyforge_project:
339
- rubygems_version: 2.2.2
339
+ rubygems_version: 2.4.5
340
340
  signing_key:
341
341
  specification_version: 4
342
342
  summary: OnSIP ruby client.