StarRezApi 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,7 +40,40 @@ class StarRezAccount
40
40
  end
41
41
 
42
42
  def self.create_transaction(entry,amount,conditions={},options={})
43
- # TODO: Get this working at some point, create_payment is good enough for now.
43
+ url = "#{base_uri}/accounts/createtransaction/#{entry}"
44
+
45
+ transaction_xml = <<XML
46
+ <Transaction>
47
+ <TransactionTypeEnum>Payment</TransactionTypeEnum>
48
+ <Amount>#{amount}</Amount>
49
+ <Description>#{conditions[:description]}</Description>
50
+ <TermSessionID>#{conditions[:term_session_id]}</TermSessionID>
51
+ <ExternalID>#{conditions[:external_id]}</ExternalID>
52
+ <Comments>#{conditions[:comments]}</Comments>
53
+ <ChargeGroupID>#{conditions[:charge_group_id]}</ChargeGroupID>
54
+ <ChargeItemID>#{conditions[:charge_item_id]}</ChargeItemID>
55
+ <SecurityUserID>6</SecurityUserID>
56
+ </Transaction>
57
+ XML
58
+ response = post(url, :body => transaction_xml)
59
+ if options[:return].eql? :response
60
+ return response
61
+ else
62
+ if response.code.eql? 409
63
+ raise ArgumentError, "Duplicate Transaction Found"
64
+ elsif response.code.eql? 404
65
+ raise ArgumentError, "Invalid Entry ID"
66
+ elsif response.code.eql? 403
67
+ raise SecurityError, 'Access Denied to API'
68
+ elsif response.code.eql? 400
69
+ raise ArgumentError, "Bad Request"
70
+ elsif response.code.eql? 200
71
+ doc = Hpricot(response.body)
72
+ doc.search("transactionid").inner_html
73
+ else
74
+ return false
75
+ end
76
+ end
44
77
  end
45
78
 
46
79
  def self.create_payment(entry,amount,conditions={},options={})
@@ -54,31 +87,33 @@ class StarRezAccount
54
87
  if charge_group[:id].present?
55
88
  charge_groups_string += %(<BreakUp ChargeGroupID="#{charge_group[:id]}">)
56
89
  elsif charge_group[:name].present?
57
- charge_groups_string += %(<BreakUp ChargeGroup="#{charge_group[:name]}">)
90
+ exi charge_groups_string += %(<BreakUp ChargeGroup="#{charge_group[:name]}">)
58
91
  else
59
92
  raise ArgumentError, "Charge group ID or name must be provided"
60
93
  end
61
94
  raise ArgumentError, "Amount must be provided for payment breakup" if charge_group[:amount].blank?
62
95
  charge_groups_string += %(<Amount>#{charge_group[:amount]}</Amount>)
63
- if charge_group[:comments].present?
64
- charge_groups_string += %(<TransactionComments>#{charge_group[:comments]}</TransactionComments>)
65
- end
66
96
  if charge_group[:tag].present?
67
97
  charge_groups_string += %(<TransactionTag>#{charge_group[:tag]}</TransactionTag>)
68
98
  end
69
99
  charge_groups_string += %(<TransactionExternalID>#{charge_group[:external_id]}</TransactionExternalID>) if charge_group[:external_id].present?
100
+ charge_groups_string += %(<TransactionTermSessionID>#{charge_group[:term_session_id]}</TransactionTermSessionID>) if charge_group[:term_session_id].present?
70
101
  charge_groups_string += %(</BreakUp>)
71
102
  end
72
103
  else
73
104
  raise ArgumentError, "At least one charge group must be provided in :charge_groups"
74
105
  end
75
106
 
107
+ amount_string = %(<Amount>#{amount}</Amount>)
108
+ description_string = %(<Description>#{conditions[:description]}</Description>)
109
+
76
110
  payment_xml = <<XML
77
111
  <Payment>
78
112
  <TransactionTypeEnum>Payment</TransactionTypeEnum>
79
113
  <PaymentTypeID>8</PaymentTypeID>
80
- <Description>#{conditions[:description]}</Description>
81
- <Amount>#{amount}</Amount>
114
+ <SecurityUserID>6</SecurityUserID>
115
+ #{description_string}
116
+ #{amount_string}
82
117
  #{charge_groups_string}
83
118
  </Payment>
84
119
  XML
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: StarRezApi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-02 00:00:00.000000000Z
13
+ date: 2011-11-04 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
17
- requirement: &70210716162720 !ruby/object:Gem::Requirement
17
+ requirement: &70282673002520 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.7.4
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70210716162720
25
+ version_requirements: *70282673002520
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: xml-simple
28
- requirement: &70210716162120 !ruby/object:Gem::Requirement
28
+ requirement: &70282673001960 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 1.0.12
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70210716162120
36
+ version_requirements: *70282673001960
37
37
  description: This gem that allows the user access to the StarRez REST Web Services,
38
38
  Reporting, and Accounts API
39
39
  email: dreedy@housing.siu.edu