advantage_quickbase 0.4.2 → 0.4.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.
Files changed (3) hide show
  1. data/lib/quickbase.rb +2 -2
  2. data/lib/user.rb +51 -0
  3. metadata +1 -1
data/lib/quickbase.rb CHANGED
@@ -274,10 +274,10 @@ module AdvantageQuickbase
274
274
  attr_value = tag.attribute(attr_name.to_s).to_s
275
275
  end
276
276
 
277
- def send_quickbase_ui_action(url)
277
+ def send_quickbase_ui_action(url, parameters={})
278
278
  url = URI.parse(url)
279
279
  request = Net::HTTP::Post.new(url.request_uri)
280
- request.set_form_data({'ticket' => @ticket })
280
+ request.set_form_data({'ticket' => @ticket }.merge(parameters))
281
281
  http = Net::HTTP.new(url.host, url.port)
282
282
  http.use_ssl = true
283
283
 
data/lib/user.rb CHANGED
@@ -71,6 +71,57 @@ module AdvantageQuickbase
71
71
  end
72
72
  end
73
73
 
74
+ def get_page_token(url)
75
+ response = send_quickbase_ui_action(url)
76
+ response.body.match(/name=PageToken value=(.*)>/)[1]
77
+ end
78
+
79
+ def remove_acct_management(account_id, emails)
80
+ user_ids = get_user_ids(emails);
81
+ user_ids.map!{ |user_id| "US" + user_id.split(".")[0] + "=12"}
82
+ user_ids = user_ids.join(",")
83
+
84
+ url = "https://#{base_domain}/db/main?a=DoAccountPerms"
85
+ url += "&accountid=#{account_id}"
86
+ page_token = get_page_token(url)
87
+
88
+ send_quickbase_ui_action(url, {'accountID' => account_id, 'retval' => user_ids, 'pageToken' => page_token})
89
+ end
90
+
91
+ def deactivate_users(account_id, emails)
92
+ remove_acct_management(account_id, emails)
93
+ user_ids = get_user_ids(emails);
94
+
95
+ url = "https://#{base_domain}/db/main?a=QBI_AccountRemoveMultiUserAccess"
96
+ url += "&accountid=#{account_id}"
97
+ url += "&removeAction=deact"
98
+ url += "&uids=" + user_ids.join(",")
99
+
100
+ result = send_quickbase_ui_action(url)
101
+ result = parse_xml( result.body )
102
+
103
+ get_tag_value(result, "numchanged")
104
+ end
105
+
106
+ def reactivate_users(account_id, emails)
107
+ user_ids = get_user_ids(emails);
108
+ numchanged = 0
109
+
110
+ url = "https://#{base_domain}/db/main?a=QBI_DeactivateUser"
111
+ url += "&cmpid=#{account_id}"
112
+ url += "&tuid="
113
+
114
+ user_ids.each do |id|
115
+ activate = url + id
116
+ result = send_quickbase_ui_action(activate)
117
+ result = parse_xml( result.body )
118
+
119
+ numchanged += 1 if get_tag_value(result, "newstatus")
120
+ end
121
+
122
+ numchanged
123
+ end
124
+
74
125
  def deny_users(account_id, emails)
75
126
  user_ids = get_user_ids(emails);
76
127
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advantage_quickbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: