shelby_arena 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10481118fe91152ecf2b01b3b9fc330854b95a4f22f73cf6f2992e2b9caa85ad
4
- data.tar.gz: a71771473869f334f87e62899d177dc90f527f48a524d325ac6a3c16c98fb36f
3
+ metadata.gz: f7c3a359d351954ae3f2aa74a9c71b01c7aaf5dcb976463032a76b434d42c6d5
4
+ data.tar.gz: 0bc07eccedb05822ee4be620e58b6031f6bd28d895bfad3bf071d8f52485f7fd
5
5
  SHA512:
6
- metadata.gz: c8cd1b36bf96c30003a42ecf07844d2186d495576b1833c181fdaed3de608cc787515218bf561916275c7359a0f32a6b262dd18725bf9c2b7b4e921a2e612c94
7
- data.tar.gz: 72d7b0bde4b069746f87c44b679c5432c48e51e36b7fc4cbb611d170be7dd59811d9459cf203c682ab887adebaa69ae332742f121d99d8ac969f067edc4e718b
6
+ metadata.gz: 6474347ea7f7abd2b9f13ea7bde94199d28f34d409ea41fb63ebbf42a82979fb115d36daaff909815eb70300f1d25257e78f224891e157136a93f136c2ad40ad
7
+ data.tar.gz: a23547ea3746dc0af2c348b4b49e3191f43e9d2eac8aa39c94930e7a79a7c51b1354acf231745058741e370643612b5f1b918e168616c522e6517d47f9bc307b
data/.ruby-version CHANGED
@@ -1 +1,2 @@
1
1
  2.7.4
2
+
@@ -1,12 +1,18 @@
1
1
  module ShelbyArena
2
2
  class Client
3
3
  module Batch
4
- def list_batches(options = {})
4
+ def list_batches(name: nil, start_date: nil, end_date: nil)
5
5
  path = 'batch/list'
6
+ options = {}
7
+
8
+ options[:batchName] = name if name
9
+ options[:startDate] = start_date if start_date
10
+ options[:endDate] = end_date if end_date
11
+
6
12
  options[:api_sig] = generate_api_sig(path, options)
7
13
 
8
14
  res = get(path, options.sort)
9
- Response::Batch.format(res.dig('BatchListResult', 'Batches', 'Batch'))
15
+ Response::Batch.format_list(res.dig('BatchListResult', 'Batches', 'Batch'))
10
16
  end
11
17
 
12
18
  def find_batch(id, options = {})
@@ -29,13 +35,14 @@ module ShelbyArena
29
35
  options[:api_sig] = generate_api_sig(path, options)
30
36
  json_body = body.to_json
31
37
 
32
- json_post("#{path}?api_session=#{options[:api_session]}&api_sig=#{options[:api_sig]}", json_body)
38
+ res = json_post("#{path}?api_session=#{options[:api_session]}&api_sig=#{options[:api_sig]}", json_body)
39
+
40
+ res.dig('ModifyResult', 'Link').split('/').last
33
41
  end
34
42
 
35
43
  def delete_batch(id, options = {})
36
44
  path = "batch/#{id}"
37
45
  options[:api_sig] = generate_api_sig(path, options)
38
- require 'pry'; binding.pry
39
46
  delete(path, options.sort)
40
47
  end
41
48
  end
@@ -4,7 +4,7 @@ module ShelbyArena
4
4
  def list_people(options = {})
5
5
  options[:api_sig] = generate_api_sig(people_path, options)
6
6
  res = get(people_path, options.sort)
7
- Response::Person.format(res.dig('PersonListResult', 'Persons', 'Person'))
7
+ Response::Person.format_list(res.dig('PersonListResult', 'Persons', 'Person'))
8
8
  end
9
9
 
10
10
  def find_people_by_name_and_email(first_name, last_name, email)
@@ -7,11 +7,26 @@ module ShelbyArena
7
7
  new(data).format
8
8
  end
9
9
 
10
+ def self.format_list(data)
11
+ new(data).format_list
12
+ end
13
+
10
14
  def initialize(data)
11
15
  @data = data
12
16
  end
13
17
 
18
+ def format_list
19
+ res = format
20
+
21
+ return [] if res.nil?
22
+ return [res] if res.is_a?(Hash)
23
+
24
+ res
25
+ end
26
+
14
27
  def format
28
+ return nil if data.nil?
29
+
15
30
  if data.is_a?(Array)
16
31
  data.map { |item| format_single(item) }
17
32
  else
@@ -22,13 +22,23 @@ module ShelbyArena
22
22
  def set_email(raw_response)
23
23
  # find_person returns an array of `Emails`
24
24
  # list_person return `FirstActiveEmail`
25
- raw_response.dig('FirstActiveEmail') || raw_response.dig('Emails', 'Email', 0, 'Address')
25
+ emails_key = parse_emails_key(raw_response.dig('Emails', 'Email'))
26
+
27
+ raw_response.dig('FirstActiveEmail') || emails_key.first
26
28
  end
27
29
 
28
30
  def set_emails(raw_response)
29
31
  # find_person returns an array of `Emails`
30
32
  # list_person return `FirstActiveEmail`
31
- raw_response.dig('Emails', 'Email')&.map { |email| email.dig('Address') } || []
33
+ parse_emails_key(raw_response.dig('Emails', 'Email'))
34
+ end
35
+
36
+ def parse_emails_key(emails_key)
37
+ if emails_key.is_a?(Array)
38
+ emails_key&.map { |email| email.dig('Address') } || []
39
+ else
40
+ [emails_key&.dig('Address')] || []
41
+ end
32
42
  end
33
43
  end
34
44
  end
@@ -1,3 +1,3 @@
1
1
  module ShelbyArena
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelby_arena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-04 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday