vivialconnect 0.0.1

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.
@@ -0,0 +1,158 @@
1
+ module VivialConnect
2
+ ##
3
+ #=== .all
4
+ #
5
+ #Returns an array containing ruby objects corresponding to all User resources on your account
6
+ #
7
+ #
8
+ # Example usage:
9
+ #
10
+ #
11
+ # VivialConnect::User.all
12
+ # => [#<VivialConnect::User account_id=1XXXX, active=true, api_key="User's Api Key", date_created="2017-04-25T09:37:47-04:00", date_modified="2017-04-25T09:38:09-04:00", email="btester@vivial.net", first_name="Bob", id=1XXXX, last_name="Test", roles=[{"active"=>true, "date_created"=>"2016-09-30T19:42:59-04:00", "date_modified"=>"2016-09-30T19:42:59-04:00", "description"=>"Account administrator role", "id"=>3, "name"=>"AccountAdministrator", "role_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:59-04:00", "date_modified"=>"2016-09-30T19:42:59-04:00", "description"=>"User role", "id"=>X, "name"=>"User", "role_type"=>"client"}], timezone="US/Eastern", username="btester", verified=true>]
13
+ #
14
+ #
15
+ ##
16
+ #=== .count
17
+ #Returns the number of users associated with your account.
18
+ #
19
+ #
20
+ # Example usage:
21
+ #
22
+ #
23
+ # VivialConnect::User.count
24
+ # => 7
25
+ #
26
+ #
27
+ #=== .find(id)
28
+ #
29
+ #Returns User object with the id provided
30
+ #
31
+ #
32
+ # Required parameter:
33
+ #
34
+ # id | Fixnum | 726
35
+ #
36
+ #
37
+ # Example usage:
38
+ #
39
+ #
40
+ # VivialConnect::User.find(726)
41
+ # => #<VivialConnect::User account_id=1XXXX, active=true, api_key="apikey", date_created="2016-12-28T11:14:58-05:00", date_modified="2017-04-25T11:59:04-04:00", email="btester@vivial.net", first_name="Bob", id=1XXXX, last_name="Tester", roles=[{"active"=>true, "date_created"=>"2016-09-30T19:42:59-04:00", "date_modified"=>"2016-09-30T19:42:59-04:00", "description"=>"Account administrator role", "id"=>3, "name"=>"AccountAdministrator", "role_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:59-04:00", "date_modified"=>"2016-09-30T19:42:59-04:00", "description"=>"User role", "id"=>4, "name"=>"User", "role_type"=>"client"}], timezone="US/Eastern", username="btester", verified=true>
42
+ #
43
+ #
44
+ ##
45
+ #=== .find_each(start: 1, finish: nil, batch_size: 150)
46
+ #
47
+ #Iterates through all of the users on your account in N sized batches and returns an array containing all the users beginning at the `start: value` and ending at the `finish: value`.
48
+ #
49
+ #
50
+ # When a block is given this method yields an individual User object.
51
+ # Without a block, this method returns an Enumerator.
52
+ #
53
+ #
54
+ # By default, it will begin at the first userr and end at the last user
55
+ #
56
+ #
57
+ # With default batch_size: 150, if you wanted to get your records from
58
+ # 150 to 300 you would start at 2 and finish at 2.
59
+ #
60
+ #
61
+ # Returns an Array of objects corresponding to the `start` and `finish` values. Default is all objects.
62
+ #
63
+ # Optional parameters:
64
+ #
65
+ # start | Fixnum | batch to start with
66
+ # finish | Fixnum | batch to end with
67
+ # batch_size | Fixnum | between 1..150
68
+ #
69
+ #
70
+ # Example usage:
71
+ #
72
+ #
73
+ # VivialConnect::User.find_each {|user| puts user.username}
74
+ # janeuser
75
+ # => [#<VivialConnect::User account_id=1XXXX>, ... ]
76
+ #
77
+ #
78
+ ##
79
+ #=== .find_in_batches(start: 1, finish: nil, batch_size: 150)
80
+ #
81
+ #Iterates through all of the user on your account in N sized batches and returns an array containing all the users beginning at the `start: value` and ending at the `finish: value`.
82
+ #
83
+ #
84
+ # When a block is given this method yields an array of batch_size resource objects.
85
+ # Without a block, it returns an Enumerator.
86
+ #
87
+ #
88
+ # By default, it will begin at the first user and end at the last user
89
+ #
90
+ #
91
+ # With default batch_size: 150, if you wanted to get your records from
92
+ # 150 to 300 you would start at 2 and finish at 2.
93
+ #
94
+ #
95
+ # Returns an Array of objects corresponding to the `start` and `finish` values. Default is all objects.
96
+ #
97
+ # Optional parameters:
98
+ #
99
+ # start | Fixnum | batch to start with
100
+ # finish | Fixnum | batch to end with
101
+ # batch_size | Fixnum | between 1..150
102
+ #
103
+ #
104
+ # Example usage:
105
+ #
106
+ #
107
+ # VivialConnect::User.find_in_batches {|batch| do_something_with_an_array(batch)}
108
+ # => [#<VivialConnect::User account_id=1XXXX> , ... ]
109
+ #
110
+ #
111
+ ##
112
+ #=== .update_password(id, old_pw, new_pw)
113
+ #
114
+ #updates the password for the user with the id passed.
115
+ #
116
+ #
117
+ # Example usage:
118
+ #
119
+ #
120
+ # VivialConnect::User.update_password(928, "oldpassword", "newpassword")
121
+ # => true
122
+ #
123
+ #
124
+ ##
125
+ #=== \#update_password(old_pw, new_pw)
126
+ #
127
+ #updates the password for the user object referenced
128
+ #
129
+ #
130
+ # Example usage:
131
+ #
132
+ #
133
+ # user = User.find(1)
134
+ # user.update_password("oldpassword", "newpassword")
135
+ # => true
136
+ #
137
+ # NOTE: there is no need to call .save here. This method updates the database.
138
+ #
139
+ #
140
+ class User < Resource
141
+
142
+ def self.update_password(id, old_pw, new_pw) # :nodoc:
143
+ data = {}
144
+ data[:user] = {_password: old_pw, password: new_pw}
145
+ data = data.to_json
146
+ response = VivialConnect::Client.instance.make_request('PUT', "/users/#{id}/profile/password.json", data)
147
+ end
148
+
149
+ def update_password(old_pw, new_pw) # :nodoc:
150
+ raise VivialConnectClientError, "your user object has no id and therefore cannot be updated" if self.id.nil?
151
+ data = {}
152
+ data[:user] = {_password: old_pw, password: new_pw}
153
+ data = data.to_json
154
+ response = VivialConnect::Client.instance.make_request('PUT', "/users/#{self.id}/profile/password.json", data)
155
+ end
156
+
157
+ end
158
+ end
@@ -0,0 +1,3 @@
1
+ module Vivialconnect # :nodoc:
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ class VivialConnectClientError < StandardError # :nodoc:
2
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vivialconnect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin LeFurjah
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.11.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.11.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: addressable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.5.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '2.5'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.5.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.14'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.14'
61
+ - !ruby/object:Gem::Dependency
62
+ name: dotenv
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.2'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.2.0
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.2'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.2.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '10.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '10.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '3.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '3.0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: simplecov
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ description: 'VivialConnect is a simple SMS/MMS API. It''s designed specifically for
124
+ developers seeking a simple, affordable and scalable messaging solution. For more
125
+ info visit: https://www.vivialconnect.net/'
126
+ email:
127
+ - jlefurjah@vivial.net
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - lib/vivialconnect.rb
133
+ - lib/vivialconnect/account.rb
134
+ - lib/vivialconnect/attachment.rb
135
+ - lib/vivialconnect/client.rb
136
+ - lib/vivialconnect/configuration.rb
137
+ - lib/vivialconnect/contact.rb
138
+ - lib/vivialconnect/log.rb
139
+ - lib/vivialconnect/message.rb
140
+ - lib/vivialconnect/number.rb
141
+ - lib/vivialconnect/resource.rb
142
+ - lib/vivialconnect/user.rb
143
+ - lib/vivialconnect/version.rb
144
+ - lib/vivialconnect/vivial_connect_error.rb
145
+ homepage: https://vivialconnect.github.io/
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 2.0.0
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.6.11
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: This is an API wrapper gem for integrating with the Vivial Connect text messaging
169
+ API.
170
+ test_files: []