usps-imis-api 0.2.1 → 0.3.1.pre.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.
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Imis
4
- module Panel
5
- class Vsc
6
- BUSINESS_OBJECT = 'ABC_ASC_Vessel_Safety_Checks'
7
-
8
- attr_reader :api
9
-
10
- def initialize(api = nil)
11
- @api = api || Api.new
12
- end
13
-
14
- def get(ordinal)
15
- api.get(BUSINESS_OBJECT, url_id: "~#{api.imis_id}|#{ordinal}")
16
- end
17
-
18
- def create(data)
19
- api.post(BUSINESS_OBJECT, payload(data), url_id: '')
20
- end
21
-
22
- def update(data)
23
- api.put(BUSINESS_OBJECT, payload(data), url_id: "~#{api.imis_id}|#{data[:ordinal]}")
24
- end
25
-
26
- def destroy(ordinal)
27
- api.delete(BUSINESS_OBJECT, url_id: "~#{api.imis_id}|#{ordinal}")
28
- end
29
-
30
- private
31
-
32
- # rubocop:disable Metrics/MethodLength
33
- def payload(data)
34
- {
35
- '$type' => 'Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts',
36
- 'EntityTypeName' => 'ABC_ASC_Vessel_Safety_Checks',
37
- 'PrimaryParentEntityTypeName' => 'Party',
38
- 'Identity' => {
39
- '$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
40
- 'EntityTypeName' => 'ABC_ASC_Vessel_Safety_Checks',
41
- 'IdentityElements' => {
42
- '$type' =>
43
- 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib',
44
- '$values' => [api.imis_id]
45
- }
46
- },
47
- 'PrimaryParentIdentity' => {
48
- '$type' => 'Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts',
49
- 'EntityTypeName' => 'Party',
50
- 'IdentityElements' => {
51
- '$type' =>
52
- 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib',
53
- '$values' => [api.imis_id]
54
- }
55
- },
56
- 'Properties' => {
57
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts',
58
- '$values' => [
59
- {
60
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
61
- 'Name' => 'ID',
62
- 'Value' => api.imis_id
63
- },
64
- (
65
- if data[:ordinal]
66
- {
67
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
68
- 'Name' => 'Ordinal',
69
- 'Value' => {
70
- '$type' => 'System.Int32',
71
- '$value' => data[:ordinal]
72
- }
73
- }
74
- end
75
- ),
76
- {
77
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
78
- 'Name' => 'Source_System',
79
- 'Value' => 'Manual ITCom Entry'
80
- },
81
- {
82
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
83
- 'Name' => 'ABC_ECertificate',
84
- 'Value' => data[:certificate]
85
- },
86
- {
87
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
88
- 'Name' => 'Activity_Type',
89
- 'Value' => 'VSC'
90
- },
91
- {
92
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
93
- 'Name' => 'Description',
94
- 'Value' => 'Vessel Safety Checks'
95
- },
96
- {
97
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
98
- 'Name' => 'Effective_Date',
99
- 'Value' => "#{data[:year]}-12-01T00:00:00"
100
- },
101
- {
102
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
103
- 'Name' => 'Quantity',
104
- 'Value' => {
105
- '$type' => 'System.Int32',
106
- '$value' => data[:count]
107
- }
108
- },
109
- {
110
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
111
- 'Name' => 'Thru_Date',
112
- 'Value' => "#{data[:year]}-12-31T00:00:00"
113
- },
114
- {
115
- '$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
116
- 'Name' => 'Transaction_Date',
117
- 'Value' => Time.now.strftime('%Y-%m-%dT%H:%M:%S')
118
- }
119
- ].compact
120
- }
121
- }
122
- end
123
- # rubocop:enable Metrics/MethodLength
124
- end
125
- end
126
- end
data/lib/usps-imis-api.rb DELETED
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Core dependencies
4
- require 'net/https'
5
- require 'json'
6
- require 'time'
7
- require 'cgi'
8
-
9
- # Extensions
10
- require 'ext/hash' unless defined?(Rails)
11
-
12
- # Internal requires
13
- require 'imis/config'
14
- require 'imis/error/api'
15
- require 'imis/error/mapper'
16
- require 'imis/api'
17
- require 'imis/mapper'
18
- require 'imis/panel/vsc'
19
-
20
- module Imis
21
- class << self
22
- def configuration
23
- @configuration ||= Imis::Config.new
24
- end
25
-
26
- def configure
27
- yield(configuration) if block_given?
28
- configuration
29
- end
30
-
31
- # def mock!(value = true)
32
- # @mock = value
33
- # end
34
-
35
- # def mock
36
- # @mock || false
37
- # end
38
- end
39
- end